msw 2.2.13 → 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.
Files changed (50) hide show
  1. package/lib/browser/index.js +7 -7
  2. package/lib/browser/index.js.map +1 -1
  3. package/lib/browser/index.mjs +7 -7
  4. package/lib/browser/index.mjs.map +1 -1
  5. package/lib/core/{GraphQLHandler-bom2Dn82.d.ts → GraphQLHandler-COiPfZ8k.d.ts} +1 -1
  6. package/lib/core/{GraphQLHandler-yJ_I6j54.d.mts → GraphQLHandler-Dq_WRbKe.d.mts} +1 -1
  7. package/lib/core/HttpResponse.d.mts +1 -1
  8. package/lib/core/HttpResponse.d.ts +1 -1
  9. package/lib/core/SetupApi.d.mts +1 -1
  10. package/lib/core/SetupApi.d.ts +1 -1
  11. package/lib/core/getResponse.d.mts +1 -1
  12. package/lib/core/getResponse.d.ts +1 -1
  13. package/lib/core/graphql.d.mts +2 -2
  14. package/lib/core/graphql.d.ts +2 -2
  15. package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
  16. package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
  17. package/lib/core/handlers/HttpHandler.d.mts +1 -1
  18. package/lib/core/handlers/HttpHandler.d.ts +1 -1
  19. package/lib/core/handlers/RequestHandler.d.mts +1 -1
  20. package/lib/core/handlers/RequestHandler.d.ts +1 -1
  21. package/lib/core/http.d.mts +1 -1
  22. package/lib/core/http.d.ts +1 -1
  23. package/lib/core/index.d.mts +2 -2
  24. package/lib/core/index.d.ts +2 -2
  25. package/lib/core/passthrough.d.mts +1 -1
  26. package/lib/core/passthrough.d.ts +1 -1
  27. package/lib/core/utils/HttpResponse/decorators.d.mts +1 -1
  28. package/lib/core/utils/HttpResponse/decorators.d.ts +1 -1
  29. package/lib/core/utils/executeHandlers.d.mts +1 -1
  30. package/lib/core/utils/executeHandlers.d.ts +1 -1
  31. package/lib/core/utils/handleRequest.d.mts +1 -1
  32. package/lib/core/utils/handleRequest.d.ts +1 -1
  33. package/lib/core/utils/internal/parseGraphQLRequest.d.mts +2 -2
  34. package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
  35. package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
  36. package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
  37. package/lib/core/utils/internal/requestHandlerUtils.d.mts +1 -1
  38. package/lib/core/utils/internal/requestHandlerUtils.d.ts +1 -1
  39. package/lib/core/utils/request/onUnhandledRequest.js +1 -1
  40. package/lib/core/utils/request/onUnhandledRequest.js.map +1 -1
  41. package/lib/core/utils/request/onUnhandledRequest.mjs +1 -1
  42. package/lib/core/utils/request/onUnhandledRequest.mjs.map +1 -1
  43. package/lib/iife/index.js +13 -11
  44. package/lib/iife/index.js.map +1 -1
  45. package/lib/mockServiceWorker.js +1 -1
  46. package/package.json +17 -5
  47. package/src/core/utils/request/onUnhandledRequest.test.ts +30 -4
  48. package/src/core/utils/request/onUnhandledRequest.ts +1 -1
  49. /package/lib/core/{HttpResponse-vQNlixkj.d.ts → HttpResponse-B07UKAkU.d.ts} +0 -0
  50. /package/lib/core/{HttpResponse-3-NyzyF7.d.mts → HttpResponse-C7niBMwb.d.mts} +0 -0
@@ -8,7 +8,7 @@
8
8
  * - Please do NOT serve this file on production.
9
9
  */
10
10
 
11
- const PACKAGE_VERSION = '2.2.13'
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.13",
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@7.12.2",
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"
@@ -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 /api
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(fixtures.warningWithoutSuggestions)
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(fixtures.warningWithoutSuggestions)
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