(page: Page)
| 10 | } |
| 11 | |
| 12 | const stopWorkerOn = async (page: Page) => { |
| 13 | page.evaluate(() => { |
| 14 | window.msw.worker.stop() |
| 15 | }) |
| 16 | |
| 17 | await new Promise<void>((resolve, reject) => { |
| 18 | const timeout = setTimeout(() => { |
| 19 | reject(new Error('Failed to await the worker stop console message!')) |
| 20 | }, 5000) |
| 21 | |
| 22 | page.on('console', (message) => { |
| 23 | const text = message.text() |
| 24 | |
| 25 | if ( |
| 26 | // Successful stop console message. |
| 27 | text.includes('[MSW] Mocking disabled.') || |
| 28 | // Warning when calling "stop()" multiple times. |
| 29 | text.includes('worker.stop()') |
| 30 | ) { |
| 31 | clearTimeout(timeout) |
| 32 | resolve() |
| 33 | } |
| 34 | }) |
| 35 | }) |
| 36 | } |
| 37 | |
| 38 | test('disables the mocking when the worker is stopped', async ({ |
| 39 | loadExample, |
no test coverage detected
searching dependent graphs…