Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(setupServer): throw InternalError in listeners as-is
- Loading branch information
1 parent
82d45c7
commit 1faf9a1
Showing
7 changed files
with
70 additions
and
15 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -29,3 +29,7 @@ export const devUtils = { | |
warn, | ||
error, | ||
} | ||
|
||
export class InternalError extends Error { | ||
// | ||
} |
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
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
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
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,50 @@ | ||
/** | ||
* @vitest-environment node | ||
*/ | ||
import { http, HttpResponse } from 'msw' | ||
import { setupServer } from 'msw/node' | ||
|
||
const server = setupServer() | ||
|
||
beforeAll(() => { | ||
server.listen() | ||
}) | ||
|
||
afterEach(() => { | ||
server.resetHandlers() | ||
}) | ||
|
||
afterAll(() => { | ||
server.close() | ||
}) | ||
|
||
it('supports mocking a response cookie', async () => { | ||
server.use( | ||
http.get('*/resource', () => { | ||
return new HttpResponse(null, { | ||
headers: { | ||
'Set-Cookie': 'a=1', | ||
}, | ||
}) | ||
}), | ||
) | ||
|
||
const response = await fetch('http://localhost/resource') | ||
expect(response.headers.get('Set-Cookie')).toBe('a=1') | ||
}) | ||
|
||
it('supports mocking multiple response cookies', async () => { | ||
server.use( | ||
http.get('*/resource', () => { | ||
return new HttpResponse(null, { | ||
headers: [ | ||
['Set-Cookie', 'a=1'], | ||
['Set-Cookie', 'b=2'], | ||
], | ||
}) | ||
}), | ||
) | ||
|
||
const response = await fetch('http://localhost/resource') | ||
expect(response.headers.get('Set-Cookie')).toBe('a=1, b=2') | ||
}) |