Skip to content

Commit

Permalink
build(deps-dev): bump msw from 1.3.2 to 2.0.5 (#259)
Browse files Browse the repository at this point in the history
* build(deps-dev): bump msw from 1.3.2 to 2.0.5

Bumps [msw](https://github.com/mswjs/msw) from 1.3.2 to 2.0.5.
- [Release notes](https://github.com/mswjs/msw/releases)
- [Changelog](https://github.com/mswjs/msw/blob/main/CHANGELOG.md)
- [Commits](mswjs/msw@v1.3.2...v2.0.5)

---
updated-dependencies:
- dependency-name: msw
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Migrate to msw 2.x

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Iain Sproat <[email protected]>
  • Loading branch information
dependabot[bot] and iainsproat authored Nov 10, 2023
1 parent c5002c7 commit f9f94ec
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 169 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-vitest": "^0.3.9",
"msw": "^1.3.2",
"msw": "^2.0.5",
"prettier": "^3.0.3",
"typescript": "^5.1.6",
"vite": "^4.5.0",
Expand Down
33 changes: 20 additions & 13 deletions tests/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { mkdtempSync, writeFileSync, rmdirSync, rmSync } from 'node:fs'
import { join } from 'node:path'
import { tmpdir } from 'node:os'
import { setupServer } from 'msw/node'
import { rest } from 'msw'
import { http, HttpResponse } from 'msw'
import { z } from 'zod'

describe('Register new version', () => {
Expand All @@ -22,30 +22,37 @@ describe('Register new version', () => {
let count500Errors = 0

const server = setupServer(
rest.post(
http.post(
'http://myfakeautomate.speckle.internal/api/v1/functions/fake_function_id/versions',
async (req, res, ctx) => {
const parseResult = FunctionVersionRequestSchema.safeParse(await req.json())
async ({ request }) => {
const parseResult = FunctionVersionRequestSchema.safeParse(await request.json())
expect(parseResult.success).to.be.true
countHappyPath++
return res(ctx.status(201), ctx.json({ versionId: 'fake_version_id' }))
return new HttpResponse(JSON.stringify({ versionId: 'fake_version_id' }), {
status: 201,
headers: {
'Content-Type': 'application/json'
}
})
}
),
rest.post(
http.post(
'http://myfakeautomate.speckle.internal/api/v1/functions/network_error/versions',
async (req, res, ctx) => {
const parseResult = FunctionVersionRequestSchema.safeParse(await req.json())
async ({ request }) => {
const parseResult = FunctionVersionRequestSchema.safeParse(await request.json())
expect(parseResult.success).to.be.true
return res.networkError('Failed to connect to server')
return HttpResponse.error() // simulates a network error
}
),
rest.post(
http.post(
'http://myfakeautomate.speckle.internal/api/v1/functions/500_response/versions',
async (req, res, ctx) => {
const parseResult = FunctionVersionRequestSchema.safeParse(await req.json())
async ({ request }) => {
const parseResult = FunctionVersionRequestSchema.safeParse(await request.json())
expect(parseResult.success).to.be.true
count500Errors++
return res(ctx.status(500))
return new HttpResponse(null, {
status: 500
})
}
)
)
Expand Down
Loading

0 comments on commit f9f94ec

Please sign in to comment.