-
-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
190 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
rules: { | ||
'body-max-line-length': [0, 'always', Infinity], | ||
'footer-max-line-length': [1, 'always'], | ||
}, | ||
} |
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
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,46 @@ | ||
import { pageWith } from 'page-with' | ||
import { waitFor } from '../../support/waitFor' | ||
|
||
function createResponseLogRegexp(username: string): RegExp { | ||
return new RegExp( | ||
`^\\[MSW\\] \\d{2}:\\d{2}:\\d{2} GET https://api\\.github\\.com/users/${username} 200 OK$`, | ||
) | ||
} | ||
|
||
test('prints the response info to the console', async () => { | ||
const runtime = await pageWith({ | ||
example: require.resolve('../../rest-api/basic.mocks.ts'), | ||
}) | ||
|
||
const waitForResponseLog = async (exp: RegExp) => { | ||
await waitFor(() => { | ||
expect(runtime.consoleSpy.get('startGroupCollapsed')).toEqual( | ||
expect.arrayContaining([expect.stringMatching(exp)]), | ||
) | ||
}) | ||
} | ||
|
||
const getResponseLogs = (exp: RegExp) => { | ||
return runtime.consoleSpy.get('startGroupCollapsed').filter((log) => { | ||
return exp.test(log) | ||
}) | ||
} | ||
|
||
const firstResponseLogRegexp = createResponseLogRegexp('octocat') | ||
await runtime.request('https://api.github.com/users/octocat') | ||
await waitForResponseLog(firstResponseLogRegexp) | ||
|
||
// Must print the response summary to the console. | ||
expect(getResponseLogs(firstResponseLogRegexp)).toHaveLength(1) | ||
|
||
const secondResopnseLogRegexp = createResponseLogRegexp('john.doe') | ||
await runtime.request('https://api.github.com/users/john.doe') | ||
await waitForResponseLog(secondResopnseLogRegexp) | ||
|
||
/** | ||
* Must not duplicate response logs for the current and previous requests. | ||
* @see https://github.com/mswjs/msw/issues/1411 | ||
*/ | ||
expect(getResponseLogs(secondResopnseLogRegexp)).toHaveLength(1) | ||
expect(getResponseLogs(firstResponseLogRegexp)).toHaveLength(1) | ||
}) |
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,3 @@ | ||
export * from 'msw' | ||
export { setupServer } from 'msw/node' | ||
export { setupServer as setupNativeServer } from 'msw/native' |
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,3 @@ | ||
export * from 'msw' | ||
export { setupServer } from 'msw/node' | ||
export { setupServer as setupNativeServer } from 'msw/native' |
Oops, something went wrong.