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.
- package/README.md +8 -1
- package/lib/core/{GraphQLHandler-CLv2BIIm.d.mts → GraphQLHandler-D4_CxZQj.d.mts} +1 -1
- package/lib/core/{GraphQLHandler-C5CUIS_N.d.ts → GraphQLHandler-Pox7fIFM.d.ts} +1 -1
- package/lib/core/{HttpResponse-CFPhtDH3.d.mts → HttpResponse-BRDnWbjc.d.mts} +4 -2
- package/lib/core/{HttpResponse-5Sn2vNaJ.d.ts → HttpResponse-Cy7ytzUn.d.ts} +4 -2
- package/lib/core/HttpResponse.d.mts +2 -1
- package/lib/core/HttpResponse.d.ts +2 -1
- package/lib/core/HttpResponse.js +4 -1
- package/lib/core/HttpResponse.js.map +1 -1
- package/lib/core/HttpResponse.mjs +4 -1
- package/lib/core/HttpResponse.mjs.map +1 -1
- package/lib/core/SetupApi.d.mts +2 -1
- package/lib/core/SetupApi.d.ts +2 -1
- package/lib/core/getResponse.d.mts +2 -1
- package/lib/core/getResponse.d.ts +2 -1
- package/lib/core/graphql.d.mts +3 -2
- package/lib/core/graphql.d.ts +3 -2
- package/lib/core/handlers/GraphQLHandler.d.mts +3 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +3 -2
- package/lib/core/handlers/HttpHandler.d.mts +2 -1
- package/lib/core/handlers/HttpHandler.d.ts +2 -1
- package/lib/core/handlers/RequestHandler.d.mts +2 -1
- package/lib/core/handlers/RequestHandler.d.ts +2 -1
- package/lib/core/http.d.mts +2 -1
- package/lib/core/http.d.ts +2 -1
- package/lib/core/index.d.mts +3 -2
- package/lib/core/index.d.ts +3 -2
- package/lib/core/passthrough.d.mts +2 -1
- package/lib/core/passthrough.d.ts +2 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +2 -1
- package/lib/core/utils/HttpResponse/decorators.d.ts +2 -1
- package/lib/core/utils/executeHandlers.d.mts +2 -1
- package/lib/core/utils/executeHandlers.d.ts +2 -1
- package/lib/core/utils/handleRequest.d.mts +2 -1
- package/lib/core/utils/handleRequest.d.ts +2 -1
- package/lib/core/utils/internal/isHandlerKind.d.mts +2 -1
- package/lib/core/utils/internal/isHandlerKind.d.ts +2 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +3 -2
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +3 -2
- package/lib/core/utils/internal/parseMultipartData.d.mts +2 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +2 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +2 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +2 -1
- package/lib/core/ws/handleWebSocketEvent.d.mts +2 -1
- package/lib/core/ws/handleWebSocketEvent.d.ts +2 -1
- package/lib/iife/index.js +3 -1
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +1 -1
- package/src/core/HttpResponse.test.ts +4 -0
- package/src/core/HttpResponse.ts +7 -4
- package/src/core/utils/handleRequest.test.ts +1 -1
package/lib/mockServiceWorker.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - Please do NOT serve this file on production.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const PACKAGE_VERSION = '2.7.
|
|
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
|
@@ -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 })
|
package/src/core/HttpResponse.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
87
|
+
accept: 'msw/invalid',
|
|
88
88
|
}),
|
|
89
89
|
})
|
|
90
90
|
const handlers: Array<RequestHandler> = [
|