msw 2.2.12 → 2.2.14
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/lib/browser/index.js +12 -9
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +12 -9
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/{GraphQLHandler-bom2Dn82.d.ts → GraphQLHandler-COiPfZ8k.d.ts} +1 -1
- package/lib/core/{GraphQLHandler-yJ_I6j54.d.mts → GraphQLHandler-Dq_WRbKe.d.mts} +1 -1
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/SetupApi.d.mts +1 -1
- package/lib/core/SetupApi.d.ts +1 -1
- package/lib/core/getResponse.d.mts +1 -1
- package/lib/core/getResponse.d.ts +1 -1
- package/lib/core/getResponse.js +2 -2
- package/lib/core/getResponse.js.map +1 -1
- package/lib/core/getResponse.mjs +2 -2
- package/lib/core/getResponse.mjs.map +1 -1
- package/lib/core/graphql.d.mts +2 -2
- package/lib/core/graphql.d.ts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
- package/lib/core/handlers/HttpHandler.d.mts +1 -1
- package/lib/core/handlers/HttpHandler.d.ts +1 -1
- package/lib/core/handlers/RequestHandler.d.mts +1 -1
- package/lib/core/handlers/RequestHandler.d.ts +1 -1
- package/lib/core/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/index.d.mts +2 -2
- package/lib/core/index.d.ts +2 -2
- package/lib/core/passthrough.d.mts +1 -1
- package/lib/core/passthrough.d.ts +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.ts +1 -1
- package/lib/core/utils/executeHandlers.d.mts +1 -1
- package/lib/core/utils/executeHandlers.d.ts +1 -1
- package/lib/core/utils/handleRequest.d.mts +1 -1
- package/lib/core/utils/handleRequest.d.ts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +2 -2
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
- package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +1 -1
- package/lib/core/utils/request/onUnhandledRequest.js +1 -1
- package/lib/core/utils/request/onUnhandledRequest.js.map +1 -1
- package/lib/core/utils/request/onUnhandledRequest.mjs +1 -1
- package/lib/core/utils/request/onUnhandledRequest.mjs.map +1 -1
- package/lib/iife/index.js +19 -19
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +18 -6
- package/src/core/getResponse.ts +2 -2
- package/src/core/handlers/GraphQLHandler.test.ts +4 -5
- package/src/core/handlers/HttpHandler.test.ts +5 -5
- package/src/core/utils/handleRequest.test.ts +14 -14
- package/src/core/utils/request/onUnhandledRequest.test.ts +30 -4
- package/src/core/utils/request/onUnhandledRequest.ts +1 -1
- package/lib/core/utils/internal/randomId.d.mts +0 -3
- package/lib/core/utils/internal/randomId.d.ts +0 -3
- package/lib/core/utils/internal/randomId.js +0 -27
- package/lib/core/utils/internal/randomId.js.map +0 -1
- package/lib/core/utils/internal/randomId.mjs +0 -7
- package/lib/core/utils/internal/randomId.mjs.map +0 -1
- package/src/core/utils/internal/randomId.ts +0 -3
- /package/lib/core/{HttpResponse-vQNlixkj.d.ts → HttpResponse-B07UKAkU.d.ts} +0 -0
- /package/lib/core/{HttpResponse-3-NyzyF7.d.mts → HttpResponse-C7niBMwb.d.mts} +0 -0
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.2.
|
|
11
|
+
const PACKAGE_VERSION = '2.2.14'
|
|
12
12
|
const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
|
|
13
13
|
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
|
14
14
|
const activeClientIds = new Set()
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "msw",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.14",
|
|
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",
|
|
7
7
|
"types": "./lib/core/index.d.ts",
|
|
8
|
-
"packageManager": "pnpm@
|
|
8
|
+
"packageManager": "pnpm@8.15.6",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./lib/core/index.d.ts",
|
|
@@ -14,22 +14,34 @@
|
|
|
14
14
|
"default": "./lib/core/index.js"
|
|
15
15
|
},
|
|
16
16
|
"./browser": {
|
|
17
|
-
"node": null,
|
|
18
17
|
"types": "./lib/browser/index.d.ts",
|
|
18
|
+
"browser": {
|
|
19
|
+
"require": "./lib/browser/index.js",
|
|
20
|
+
"import": "./lib/browser/index.mjs"
|
|
21
|
+
},
|
|
22
|
+
"node": null,
|
|
19
23
|
"require": "./lib/browser/index.js",
|
|
20
24
|
"import": "./lib/browser/index.mjs",
|
|
21
25
|
"default": "./lib/browser/index.js"
|
|
22
26
|
},
|
|
23
27
|
"./node": {
|
|
24
|
-
"browser": null,
|
|
25
28
|
"types": "./lib/node/index.d.ts",
|
|
29
|
+
"node": {
|
|
30
|
+
"require": "./lib/node/index.js",
|
|
31
|
+
"import": "./lib/node/index.mjs"
|
|
32
|
+
},
|
|
33
|
+
"browser": null,
|
|
26
34
|
"require": "./lib/node/index.js",
|
|
27
35
|
"import": "./lib/node/index.mjs",
|
|
28
36
|
"default": "./lib/node/index.mjs"
|
|
29
37
|
},
|
|
30
38
|
"./native": {
|
|
31
|
-
"browser": null,
|
|
32
39
|
"types": "./lib/native/index.d.ts",
|
|
40
|
+
"react-native": {
|
|
41
|
+
"require": "./lib/native/index.js",
|
|
42
|
+
"import": "./lib/native/index.mjs"
|
|
43
|
+
},
|
|
44
|
+
"browser": null,
|
|
33
45
|
"require": "./lib/native/index.js",
|
|
34
46
|
"import": "./lib/native/index.mjs",
|
|
35
47
|
"default": "./lib/native/index.js"
|
|
@@ -105,7 +117,7 @@
|
|
|
105
117
|
"@bundled-es-modules/statuses": "^1.0.1",
|
|
106
118
|
"@inquirer/confirm": "^3.0.0",
|
|
107
119
|
"@mswjs/cookies": "^1.1.0",
|
|
108
|
-
"@mswjs/interceptors": "^0.26.
|
|
120
|
+
"@mswjs/interceptors": "^0.26.14",
|
|
109
121
|
"@open-draft/until": "^2.1.0",
|
|
110
122
|
"@types/cookie": "^0.6.0",
|
|
111
123
|
"@types/statuses": "^2.0.4",
|
package/src/core/getResponse.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { createRequestId } from '@mswjs/interceptors'
|
|
1
2
|
import type { RequestHandler } from './handlers/RequestHandler'
|
|
2
3
|
import { executeHandlers } from './utils/executeHandlers'
|
|
3
|
-
import { randomId } from './utils/internal/randomId'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Finds a response for the given request instance
|
|
@@ -15,7 +15,7 @@ export const getResponse = async (
|
|
|
15
15
|
): Promise<Response | undefined> => {
|
|
16
16
|
const result = await executeHandlers({
|
|
17
17
|
request,
|
|
18
|
-
requestId:
|
|
18
|
+
requestId: createRequestId(),
|
|
19
19
|
handlers,
|
|
20
20
|
})
|
|
21
21
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @vitest-environment jsdom
|
|
3
3
|
*/
|
|
4
|
-
import { encodeBuffer } from '@mswjs/interceptors'
|
|
4
|
+
import { createRequestId, encodeBuffer } from '@mswjs/interceptors'
|
|
5
5
|
import { OperationTypeNode, parse } from 'graphql'
|
|
6
6
|
import {
|
|
7
7
|
GraphQLHandler,
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
GraphQLResolverExtras,
|
|
10
10
|
isDocumentNode,
|
|
11
11
|
} from './GraphQLHandler'
|
|
12
|
-
import { randomId } from '../utils/internal/randomId'
|
|
13
12
|
import { HttpResponse } from '../HttpResponse'
|
|
14
13
|
import { ResponseResolver } from './RequestHandler'
|
|
15
14
|
|
|
@@ -737,7 +736,7 @@ describe('run', () => {
|
|
|
737
736
|
userId: 'abc-123',
|
|
738
737
|
},
|
|
739
738
|
})
|
|
740
|
-
const requestId =
|
|
739
|
+
const requestId = createRequestId()
|
|
741
740
|
const result = await handler.run({ request, requestId })
|
|
742
741
|
|
|
743
742
|
expect(result!.handler).toEqual(handler)
|
|
@@ -779,7 +778,7 @@ describe('run', () => {
|
|
|
779
778
|
const request = createPostGraphQLRequest({
|
|
780
779
|
query: LOGIN,
|
|
781
780
|
})
|
|
782
|
-
const requestId =
|
|
781
|
+
const requestId = createRequestId()
|
|
783
782
|
const result = await handler.run({ request, requestId })
|
|
784
783
|
|
|
785
784
|
expect(result).toBeNull()
|
|
@@ -827,7 +826,7 @@ describe('request', () => {
|
|
|
827
826
|
`,
|
|
828
827
|
})
|
|
829
828
|
|
|
830
|
-
const requestId =
|
|
829
|
+
const requestId = createRequestId()
|
|
831
830
|
await handler.run({ request, requestId })
|
|
832
831
|
|
|
833
832
|
expect(matchAllResolver).toHaveBeenCalledTimes(1)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @vitest-environment jsdom
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { createRequestId } from '@mswjs/interceptors'
|
|
5
5
|
import { HttpHandler, HttpRequestResolverExtras } from './HttpHandler'
|
|
6
6
|
import { HttpResponse } from '..'
|
|
7
7
|
import { ResponseResolver } from './RequestHandler'
|
|
@@ -152,7 +152,7 @@ describe('run', () => {
|
|
|
152
152
|
test('returns a mocked response given a matching request', async () => {
|
|
153
153
|
const handler = new HttpHandler('GET', '/user/:userId', resolver)
|
|
154
154
|
const request = new Request(new URL('/user/abc-123', location.href))
|
|
155
|
-
const requestId =
|
|
155
|
+
const requestId = createRequestId()
|
|
156
156
|
const result = await handler.run({ request, requestId })
|
|
157
157
|
|
|
158
158
|
expect(result!.handler).toEqual(handler)
|
|
@@ -176,7 +176,7 @@ describe('run', () => {
|
|
|
176
176
|
const handler = new HttpHandler('POST', '/login', resolver)
|
|
177
177
|
const result = await handler.run({
|
|
178
178
|
request: new Request(new URL('/users', location.href)),
|
|
179
|
-
requestId:
|
|
179
|
+
requestId: createRequestId(),
|
|
180
180
|
})
|
|
181
181
|
|
|
182
182
|
expect(result).toBeNull()
|
|
@@ -186,7 +186,7 @@ describe('run', () => {
|
|
|
186
186
|
const handler = new HttpHandler('GET', '/users', resolver)
|
|
187
187
|
const result = await handler.run({
|
|
188
188
|
request: new Request(new URL('/users', location.href)),
|
|
189
|
-
requestId:
|
|
189
|
+
requestId: createRequestId(),
|
|
190
190
|
})
|
|
191
191
|
|
|
192
192
|
expect(result?.parsedResult?.match?.params).toEqual({})
|
|
@@ -207,7 +207,7 @@ describe('run', () => {
|
|
|
207
207
|
const run = async () => {
|
|
208
208
|
const result = await handler.run({
|
|
209
209
|
request: new Request(new URL('/users', location.href)),
|
|
210
|
-
requestId:
|
|
210
|
+
requestId: createRequestId(),
|
|
211
211
|
})
|
|
212
212
|
return result?.response?.text()
|
|
213
213
|
}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* @vitest-environment jsdom
|
|
3
3
|
*/
|
|
4
4
|
import { Emitter } from 'strict-event-emitter'
|
|
5
|
+
import { createRequestId } from '@mswjs/interceptors'
|
|
5
6
|
import { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'
|
|
6
7
|
import { RequestHandler } from '../handlers/RequestHandler'
|
|
7
8
|
import { http } from '../http'
|
|
8
9
|
import { handleRequest, HandleRequestOptions } from './handleRequest'
|
|
9
10
|
import { RequiredDeep } from '../typeUtils'
|
|
10
|
-
import { randomId } from './internal/randomId'
|
|
11
11
|
import { HttpResponse } from '../HttpResponse'
|
|
12
12
|
import { passthrough } from '../passthrough'
|
|
13
13
|
|
|
@@ -51,7 +51,7 @@ afterEach(() => {
|
|
|
51
51
|
test('returns undefined for a request with the "x-msw-intention" header equal to "bypass"', async () => {
|
|
52
52
|
const { emitter, events } = setup()
|
|
53
53
|
|
|
54
|
-
const requestId =
|
|
54
|
+
const requestId = createRequestId()
|
|
55
55
|
const request = new Request(new URL('http://localhost/user'), {
|
|
56
56
|
headers: new Headers({
|
|
57
57
|
'x-msw-intention': 'bypass',
|
|
@@ -97,7 +97,7 @@ test('does not bypass a request with "x-msw-intention" header set to arbitrary v
|
|
|
97
97
|
|
|
98
98
|
const result = await handleRequest(
|
|
99
99
|
request,
|
|
100
|
-
|
|
100
|
+
createRequestId(),
|
|
101
101
|
handlers,
|
|
102
102
|
options,
|
|
103
103
|
emitter,
|
|
@@ -112,7 +112,7 @@ test('does not bypass a request with "x-msw-intention" header set to arbitrary v
|
|
|
112
112
|
test('reports request as unhandled when it has no matching request handlers', async () => {
|
|
113
113
|
const { emitter, events } = setup()
|
|
114
114
|
|
|
115
|
-
const requestId =
|
|
115
|
+
const requestId = createRequestId()
|
|
116
116
|
const request = new Request(new URL('http://localhost/user'))
|
|
117
117
|
const handlers: Array<RequestHandler> = []
|
|
118
118
|
|
|
@@ -145,7 +145,7 @@ test('reports request as unhandled when it has no matching request handlers', as
|
|
|
145
145
|
test('returns undefined on a request handler that returns no response', async () => {
|
|
146
146
|
const { emitter, events } = setup()
|
|
147
147
|
|
|
148
|
-
const requestId =
|
|
148
|
+
const requestId = createRequestId()
|
|
149
149
|
const request = new Request(new URL('http://localhost/user'))
|
|
150
150
|
const handlers: Array<RequestHandler> = [
|
|
151
151
|
http.get('/user', () => {
|
|
@@ -184,7 +184,7 @@ test('returns undefined on a request handler that returns no response', async ()
|
|
|
184
184
|
test('returns the mocked response for a request with a matching request handler', async () => {
|
|
185
185
|
const { emitter, events } = setup()
|
|
186
186
|
|
|
187
|
-
const requestId =
|
|
187
|
+
const requestId = createRequestId()
|
|
188
188
|
const request = new Request(new URL('http://localhost/user'))
|
|
189
189
|
const mockedResponse = HttpResponse.json({ firstName: 'John' })
|
|
190
190
|
const handlers: Array<RequestHandler> = [
|
|
@@ -242,7 +242,7 @@ test('returns the mocked response for a request with a matching request handler'
|
|
|
242
242
|
test('returns a transformed response if the "transformResponse" option is provided', async () => {
|
|
243
243
|
const { emitter, events } = setup()
|
|
244
244
|
|
|
245
|
-
const requestId =
|
|
245
|
+
const requestId = createRequestId()
|
|
246
246
|
const request = new Request(new URL('http://localhost/user'))
|
|
247
247
|
const mockedResponse = HttpResponse.json({ firstName: 'John' })
|
|
248
248
|
const handlers: Array<RequestHandler> = [
|
|
@@ -325,7 +325,7 @@ test('returns a transformed response if the "transformResponse" option is provid
|
|
|
325
325
|
it('returns undefined without warning on a passthrough request', async () => {
|
|
326
326
|
const { emitter, events } = setup()
|
|
327
327
|
|
|
328
|
-
const requestId =
|
|
328
|
+
const requestId = createRequestId()
|
|
329
329
|
const request = new Request(new URL('http://localhost/user'))
|
|
330
330
|
const handlers: Array<RequestHandler> = [
|
|
331
331
|
http.get('/user', () => {
|
|
@@ -358,7 +358,7 @@ it('returns undefined without warning on a passthrough request', async () => {
|
|
|
358
358
|
it('calls the handler with the requestId', async () => {
|
|
359
359
|
const { emitter } = setup()
|
|
360
360
|
|
|
361
|
-
const requestId =
|
|
361
|
+
const requestId = createRequestId()
|
|
362
362
|
const request = new Request(new URL('http://localhost/user'))
|
|
363
363
|
const handlerFn = vi.fn()
|
|
364
364
|
const handlers: Array<RequestHandler> = [http.get('/user', handlerFn)]
|
|
@@ -390,7 +390,7 @@ it('marks the first matching one-time handler as used', async () => {
|
|
|
390
390
|
})
|
|
391
391
|
const handlers: Array<RequestHandler> = [oneTimeHandler, anotherHandler]
|
|
392
392
|
|
|
393
|
-
const requestId =
|
|
393
|
+
const requestId = createRequestId()
|
|
394
394
|
const request = new Request('http://localhost/resource')
|
|
395
395
|
const firstResult = await handleRequest(
|
|
396
396
|
request,
|
|
@@ -438,7 +438,7 @@ it('does not mark non-matching one-time handlers as used', async () => {
|
|
|
438
438
|
)
|
|
439
439
|
const handlers: Array<RequestHandler> = [oneTimeHandler, anotherHandler]
|
|
440
440
|
|
|
441
|
-
const requestId =
|
|
441
|
+
const requestId = createRequestId()
|
|
442
442
|
const firstResult = await handleRequest(
|
|
443
443
|
new Request('http://localhost/another'),
|
|
444
444
|
requestId,
|
|
@@ -481,7 +481,7 @@ it('handles parallel requests with one-time handlers', async () => {
|
|
|
481
481
|
})
|
|
482
482
|
const handlers: Array<RequestHandler> = [oneTimeHandler, anotherHandler]
|
|
483
483
|
|
|
484
|
-
const requestId =
|
|
484
|
+
const requestId = createRequestId()
|
|
485
485
|
const request = new Request('http://localhost/resource')
|
|
486
486
|
const firstResultPromise = handleRequest(
|
|
487
487
|
request,
|
|
@@ -526,7 +526,7 @@ describe('[Private] - resolutionContext - used for extensions', () => {
|
|
|
526
526
|
|
|
527
527
|
const handlers: Array<RequestHandler> = [handler]
|
|
528
528
|
|
|
529
|
-
const requestId =
|
|
529
|
+
const requestId = createRequestId()
|
|
530
530
|
const request = new Request(new URL('/resource', baseUrl))
|
|
531
531
|
const response = await handleRequest(
|
|
532
532
|
request,
|
|
@@ -555,7 +555,7 @@ describe('[Private] - resolutionContext - used for extensions', () => {
|
|
|
555
555
|
|
|
556
556
|
const handlers: Array<RequestHandler> = [handler]
|
|
557
557
|
|
|
558
|
-
const requestId =
|
|
558
|
+
const requestId = createRequestId()
|
|
559
559
|
const request = new Request(
|
|
560
560
|
new URL('/resource', `http://not-the-base-url.com`),
|
|
561
561
|
)
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
} from './onUnhandledRequest'
|
|
8
8
|
|
|
9
9
|
const fixtures = {
|
|
10
|
-
warningWithoutSuggestions: `\
|
|
10
|
+
warningWithoutSuggestions: (url = `/api`) => `\
|
|
11
11
|
[MSW] Warning: intercepted a request without a matching request handler:
|
|
12
12
|
|
|
13
|
-
• GET
|
|
13
|
+
• GET ${url}
|
|
14
14
|
|
|
15
15
|
If you still wish to intercept this unhandled request, please create a request handler for it.
|
|
16
16
|
Read more: https://mswjs.io/docs/getting-started/mocks`,
|
|
@@ -46,7 +46,9 @@ test('supports the "bypass" request strategy', async () => {
|
|
|
46
46
|
test('supports the "warn" request strategy', async () => {
|
|
47
47
|
await onUnhandledRequest(new Request(new URL('http://localhost/api')), 'warn')
|
|
48
48
|
|
|
49
|
-
expect(console.warn).toHaveBeenCalledWith(
|
|
49
|
+
expect(console.warn).toHaveBeenCalledWith(
|
|
50
|
+
fixtures.warningWithoutSuggestions(),
|
|
51
|
+
)
|
|
50
52
|
})
|
|
51
53
|
|
|
52
54
|
test('supports the "error" request strategy', async () => {
|
|
@@ -103,7 +105,9 @@ test('supports calling default strategies from the custom callback function', as
|
|
|
103
105
|
test('does not print any suggestions given no handlers to suggest', async () => {
|
|
104
106
|
await onUnhandledRequest(new Request(new URL('http://localhost/api')), 'warn')
|
|
105
107
|
|
|
106
|
-
expect(console.warn).toHaveBeenCalledWith(
|
|
108
|
+
expect(console.warn).toHaveBeenCalledWith(
|
|
109
|
+
fixtures.warningWithoutSuggestions(),
|
|
110
|
+
)
|
|
107
111
|
})
|
|
108
112
|
|
|
109
113
|
test('throws an exception given unknown request strategy', async () => {
|
|
@@ -117,3 +121,25 @@ test('throws an exception given unknown request strategy', async () => {
|
|
|
117
121
|
'[MSW] Failed to react to an unhandled request: unknown strategy "invalid-strategy". Please provide one of the supported strategies ("bypass", "warn", "error") or a custom callback function as the value of the "onUnhandledRequest" option.',
|
|
118
122
|
)
|
|
119
123
|
})
|
|
124
|
+
|
|
125
|
+
test('prints with a relative URL and search params', async () => {
|
|
126
|
+
await onUnhandledRequest(
|
|
127
|
+
new Request(new URL('http://localhost/api?foo=boo')),
|
|
128
|
+
'warn',
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
expect(console.warn).toHaveBeenCalledWith(
|
|
132
|
+
fixtures.warningWithoutSuggestions(`/api?foo=boo`),
|
|
133
|
+
)
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
test('prints with an absolute URL and search params', async () => {
|
|
137
|
+
await onUnhandledRequest(
|
|
138
|
+
new Request(new URL('https://mswjs.io/api?foo=boo')),
|
|
139
|
+
'warn',
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
expect(console.warn).toHaveBeenCalledWith(
|
|
143
|
+
fixtures.warningWithoutSuggestions(`https://mswjs.io/api?foo=boo`),
|
|
144
|
+
)
|
|
145
|
+
})
|
|
@@ -22,7 +22,7 @@ export async function onUnhandledRequest(
|
|
|
22
22
|
strategy: UnhandledRequestStrategy = 'warn',
|
|
23
23
|
): Promise<void> {
|
|
24
24
|
const url = new URL(request.url)
|
|
25
|
-
const publicUrl = toPublicUrl(url)
|
|
25
|
+
const publicUrl = toPublicUrl(url) + url.search
|
|
26
26
|
|
|
27
27
|
const unhandledRequestMessage = `intercepted a request without a matching request handler:\n\n \u2022 ${request.method} ${publicUrl}\n\nIf you still wish to intercept this unhandled request, please create a request handler for it.\nRead more: https://mswjs.io/docs/getting-started/mocks`
|
|
28
28
|
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var randomId_exports = {};
|
|
20
|
-
__export(randomId_exports, {
|
|
21
|
-
randomId: () => randomId
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(randomId_exports);
|
|
24
|
-
function randomId() {
|
|
25
|
-
return Math.random().toString(16).slice(2);
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=randomId.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/internal/randomId.ts"],"sourcesContent":["export function randomId(): string {\n return Math.random().toString(16).slice(2)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,WAAmB;AACjC,SAAO,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC;AAC3C;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/internal/randomId.ts"],"sourcesContent":["export function randomId(): string {\n return Math.random().toString(16).slice(2)\n}\n"],"mappings":"AAAO,SAAS,WAAmB;AACjC,SAAO,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC;AAC3C;","names":[]}
|
|
File without changes
|
|
File without changes
|