Skip to content

Commit 40c5255

Browse files
committed
test: use test server vs example.com
1 parent 0735456 commit 40c5255

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

  • test/browser/msw-api/setup-worker/start/on-unhandled-request

test/browser/msw-api/setup-worker/start/on-unhandled-request/warn.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ test('warns on an unhandled REST API request with an absolute URL', async ({
44
loadExample,
55
spyOnConsole,
66
fetch,
7+
createServer,
78
}) => {
9+
const server = await createServer((app) => {
10+
app.get('/resource', (req, res) => res.status(404).end())
11+
})
812
const consoleSpy = spyOnConsole()
913
await loadExample(new URL('./warn.mocks.ts', import.meta.url))
1014

11-
const res = await fetch('https://mswjs.io/non-existing-page')
15+
const res = await fetch(server.http.url('/resource'))
1216
const status = res.status()
1317

1418
expect(status).toBe(404)
@@ -17,7 +21,7 @@ test('warns on an unhandled REST API request with an absolute URL', async ({
1721
expect.stringContaining(`\
1822
[MSW] Warning: intercepted a request without a matching request handler:
1923
20-
• GET https://mswjs.io/non-existing-page
24+
• GET ${server.http.url('/resource')}
2125
2226
If you still wish to intercept this unhandled request, please create a request handler for it.
2327
Read more: https://mswjs.io/docs/http/intercepting-requests`),
@@ -102,7 +106,7 @@ test('ignores common static assets when using the "warn" strategy', async ({
102106

103107
// This request will error so perform it accordingly.
104108
await page.evaluate(() => {
105-
return fetch('https://example.com/styles/main.css').catch(() => null)
109+
return fetch('http://localhost/styles/main.css').catch(() => null)
106110
})
107111

108112
expect(consoleSpy.get('warning')).toBeUndefined()

0 commit comments

Comments
 (0)