Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
// @vitest-environment node
import { HttpServer } from '@open-draft/test-server/http'
import { FetchInterceptor } from '#/src/interceptors/fetch/web'

const httpServer = new HttpServer((app) => {
app.get('/resource', (req, res) => {
res.send('original response')
})
})
import { getTestServer } from '#/test/setup/vitest'
import { FetchInterceptor } from '@mswjs/interceptors/fetch'

const server = getTestServer()
const interceptor = new FetchInterceptor()

beforeAll(async () => {
interceptor.apply()
await httpServer.listen()
})

afterEach(() => {
Expand All @@ -21,7 +15,6 @@

afterAll(async () => {
interceptor.dispose()
await httpServer.close()
})

it('awaits response listener promise before resolving the mocked response promise', async () => {
Expand All @@ -38,7 +31,7 @@
})

markStep(1)
await fetch('http://localhost/')
await fetch(server.http.url('/resource'))
markStep(4)

expect(markStep).toHaveBeenNthCalledWith(1, 1)
Expand All @@ -57,11 +50,11 @@
})

markStep(1)
await fetch(httpServer.http.url('/resource'))
await fetch(server.http.url('/resource'))
markStep(4)

expect(markStep).toHaveBeenNthCalledWith(1, 1)
expect(markStep).toHaveBeenNthCalledWith(2, 2)
expect(markStep).toHaveBeenNthCalledWith(3, 3)

Check failure on line 58 in test/modules/fetch/response/fetch-await-response-event.neutral.test.ts

View workflow job for this annotation

GitHub Actions / build (24)

[node] modules/fetch/response/fetch-await-response-event.neutral.test.ts > awaits response listener promise before resolving the original response promise

AssertionError: expected 3rd "vi.fn()" call to have been called with [ 3 ] - Expected + Received [ - 3, + 4, ] ❯ modules/fetch/response/fetch-await-response-event.neutral.test.ts:58:20

Check failure on line 58 in test/modules/fetch/response/fetch-await-response-event.neutral.test.ts

View workflow job for this annotation

GitHub Actions / build (22)

[node] modules/fetch/response/fetch-await-response-event.neutral.test.ts > awaits response listener promise before resolving the original response promise

AssertionError: expected 3rd "vi.fn()" call to have been called with [ 3 ] - Expected + Received [ - 3, + 4, ] ❯ modules/fetch/response/fetch-await-response-event.neutral.test.ts:58:20
expect(markStep).toHaveBeenNthCalledWith(4, 4)
})
1 change: 0 additions & 1 deletion test/modules/http/compliance/http-modify-request.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @vitest-environment node
import http from 'node:http'
import { HttpServer } from '@open-draft/test-server/http'
import { HttpRequestInterceptor } from '#/src/interceptors/http'
import { toWebResponse } from '#/test/helpers'
import { getTestServer } from '#/test/setup/vitest'
Expand Down
Loading