msw 2.7.0 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +8 -1
  2. package/lib/core/{GraphQLHandler-CLv2BIIm.d.mts → GraphQLHandler-D4_CxZQj.d.mts} +1 -1
  3. package/lib/core/{GraphQLHandler-C5CUIS_N.d.ts → GraphQLHandler-Pox7fIFM.d.ts} +1 -1
  4. package/lib/core/{HttpResponse-CFPhtDH3.d.mts → HttpResponse-BRDnWbjc.d.mts} +4 -2
  5. package/lib/core/{HttpResponse-5Sn2vNaJ.d.ts → HttpResponse-Cy7ytzUn.d.ts} +4 -2
  6. package/lib/core/HttpResponse.d.mts +2 -1
  7. package/lib/core/HttpResponse.d.ts +2 -1
  8. package/lib/core/HttpResponse.js +4 -1
  9. package/lib/core/HttpResponse.js.map +1 -1
  10. package/lib/core/HttpResponse.mjs +4 -1
  11. package/lib/core/HttpResponse.mjs.map +1 -1
  12. package/lib/core/SetupApi.d.mts +2 -1
  13. package/lib/core/SetupApi.d.ts +2 -1
  14. package/lib/core/getResponse.d.mts +2 -1
  15. package/lib/core/getResponse.d.ts +2 -1
  16. package/lib/core/graphql.d.mts +3 -2
  17. package/lib/core/graphql.d.ts +3 -2
  18. package/lib/core/handlers/GraphQLHandler.d.mts +3 -2
  19. package/lib/core/handlers/GraphQLHandler.d.ts +3 -2
  20. package/lib/core/handlers/HttpHandler.d.mts +2 -1
  21. package/lib/core/handlers/HttpHandler.d.ts +2 -1
  22. package/lib/core/handlers/RequestHandler.d.mts +2 -1
  23. package/lib/core/handlers/RequestHandler.d.ts +2 -1
  24. package/lib/core/http.d.mts +2 -1
  25. package/lib/core/http.d.ts +2 -1
  26. package/lib/core/index.d.mts +3 -2
  27. package/lib/core/index.d.ts +3 -2
  28. package/lib/core/passthrough.d.mts +2 -1
  29. package/lib/core/passthrough.d.ts +2 -1
  30. package/lib/core/utils/HttpResponse/decorators.d.mts +2 -1
  31. package/lib/core/utils/HttpResponse/decorators.d.ts +2 -1
  32. package/lib/core/utils/executeHandlers.d.mts +2 -1
  33. package/lib/core/utils/executeHandlers.d.ts +2 -1
  34. package/lib/core/utils/handleRequest.d.mts +2 -1
  35. package/lib/core/utils/handleRequest.d.ts +2 -1
  36. package/lib/core/utils/internal/isHandlerKind.d.mts +2 -1
  37. package/lib/core/utils/internal/isHandlerKind.d.ts +2 -1
  38. package/lib/core/utils/internal/parseGraphQLRequest.d.mts +3 -2
  39. package/lib/core/utils/internal/parseGraphQLRequest.d.ts +3 -2
  40. package/lib/core/utils/internal/parseMultipartData.d.mts +2 -1
  41. package/lib/core/utils/internal/parseMultipartData.d.ts +2 -1
  42. package/lib/core/utils/internal/requestHandlerUtils.d.mts +2 -1
  43. package/lib/core/utils/internal/requestHandlerUtils.d.ts +2 -1
  44. package/lib/core/ws/handleWebSocketEvent.d.mts +2 -1
  45. package/lib/core/ws/handleWebSocketEvent.d.ts +2 -1
  46. package/lib/iife/index.js +3 -1
  47. package/lib/iife/index.js.map +1 -1
  48. package/lib/mockServiceWorker.js +1 -1
  49. package/package.json +1 -1
  50. package/src/core/HttpResponse.test.ts +4 -0
  51. package/src/core/HttpResponse.ts +7 -4
  52. package/src/core/utils/handleRequest.test.ts +1 -1
@@ -8,7 +8,7 @@
8
8
  * - Please do NOT serve this file on production.
9
9
  */
10
10
 
11
- const PACKAGE_VERSION = '2.7.0'
11
+ const PACKAGE_VERSION = '2.7.2'
12
12
  const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f'
13
13
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
14
14
  const activeClientIds = new Set()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "msw",
3
- "version": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
5
5
  "main": "./lib/core/index.js",
6
6
  "module": "./lib/core/index.mjs",
@@ -13,6 +13,10 @@ it('creates a plain response', async () => {
13
13
  expect(Object.fromEntries(response.headers.entries())).toEqual({})
14
14
  })
15
15
 
16
+ it('supports non-configurable status codes', () => {
17
+ expect(new HttpResponse(null, { status: 101 })).toHaveProperty('status', 101)
18
+ })
19
+
16
20
  describe('HttpResponse.text()', () => {
17
21
  it('creates a text response', async () => {
18
22
  const response = HttpResponse.text('hello world', { status: 201 })
@@ -1,3 +1,4 @@
1
+ import { FetchResponse } from '@mswjs/interceptors'
1
2
  import type { DefaultBodyType, JsonBodyType } from './handlers/RequestHandler'
2
3
  import type { NoInfer } from './typeUtils'
3
4
  import {
@@ -5,12 +6,12 @@ import {
5
6
  normalizeResponseInit,
6
7
  } from './utils/HttpResponse/decorators'
7
8
 
9
+ const bodyType = Symbol('bodyType')
10
+
8
11
  export interface HttpResponseInit extends ResponseInit {
9
12
  type?: ResponseType
10
13
  }
11
14
 
12
- declare const bodyType: unique symbol
13
-
14
15
  export interface StrictRequest<BodyType extends DefaultBodyType>
15
16
  extends Request {
16
17
  json(): Promise<BodyType>
@@ -35,7 +36,9 @@ export interface StrictResponse<BodyType extends DefaultBodyType>
35
36
  *
36
37
  * @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}
37
38
  */
38
- export class HttpResponse extends Response {
39
+ export class HttpResponse extends FetchResponse {
40
+ readonly [bodyType]: any
41
+
39
42
  constructor(body?: BodyInit | null, init?: HttpResponseInit) {
40
43
  const responseInit = normalizeResponseInit(init)
41
44
  super(body, responseInit)
@@ -167,7 +170,7 @@ export class HttpResponse extends Response {
167
170
  responseInit.headers.set('Content-Length', body.byteLength.toString())
168
171
  }
169
172
 
170
- return new HttpResponse(body, responseInit)
173
+ return new HttpResponse(body as ArrayBuffer, responseInit)
171
174
  }
172
175
 
173
176
  /**
@@ -84,7 +84,7 @@ test('does not bypass a request with "accept: msw/*" header set to arbitrary val
84
84
 
85
85
  const request = new Request(new URL('http://localhost/user'), {
86
86
  headers: new Headers({
87
- acceot: 'msw/invalid',
87
+ accept: 'msw/invalid',
88
88
  }),
89
89
  })
90
90
  const handlers: Array<RequestHandler> = [