-
-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add fetch relative url test in jsdom
- Loading branch information
1 parent
17bf9fc
commit 9485aea
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
test/node/rest-api/request/matching/relative-url.node.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @vitest-environment jsdom | ||
*/ | ||
import { http, HttpResponse } from 'msw' | ||
import { setupServer } from 'msw/node' | ||
|
||
const server = setupServer( | ||
http.get('/api/movies', () => { | ||
return HttpResponse.json([ | ||
{ title: 'The Lord of the Rings' }, | ||
{ title: 'The Matrix' }, | ||
]) | ||
}), | ||
) | ||
|
||
beforeAll(() => { | ||
server.listen() | ||
}) | ||
|
||
afterAll(() => { | ||
server.close() | ||
}) | ||
|
||
it('responds to a relative URL in jsdom', async () => { | ||
const response = await fetch('/api/movies') | ||
|
||
expect(response.status).toBe(200) | ||
expect(await response.json()).toEqual([ | ||
{ title: 'The Lord of the Rings' }, | ||
{ title: 'The Matrix' }, | ||
]) | ||
}) |