|
15 | 15 | * limitations under the License. |
16 | 16 | */ |
17 | 17 |
|
18 | | -import { it, expect, options } from './playwright.fixtures'; |
| 18 | +import domain from 'domain'; |
| 19 | +import { it, expect, options, playwrightFixtures } from './playwright.fixtures'; |
19 | 20 | import type { ChromiumBrowser } from '..'; |
20 | 21 |
|
| 22 | +playwrightFixtures.defineWorkerFixture('domain', async ({ }, test) => { |
| 23 | + const local = domain.create(); |
| 24 | + local.run(() => { }); |
| 25 | + let err; |
| 26 | + local.on('error', e => err = e); |
| 27 | + local.enter(); |
| 28 | + await test(null); |
| 29 | + if (err) |
| 30 | + throw err; |
| 31 | +}); |
| 32 | + |
21 | 33 | it('should work', async ({browser}) => { |
22 | 34 | expect(!!browser['_connection']).toBeTruthy(); |
23 | 35 | }); |
@@ -144,6 +156,14 @@ it('should scope browser handles', async ({browserType, defaultBrowserOptions}) |
144 | 156 | await expectScopeState(browserType, GOLDEN_PRECONDITION); |
145 | 157 | }); |
146 | 158 |
|
| 159 | +it('should work with the domain module', async ({ domain, browserType }) => { |
| 160 | + const browser = await browserType.launch(); |
| 161 | + const page = await browser.newPage(); |
| 162 | + const result = await page.evaluate(() => 1 + 1); |
| 163 | + expect(result).toBe(2); |
| 164 | + await browser.close(); |
| 165 | +}); |
| 166 | + |
147 | 167 | async function expectScopeState(object, golden) { |
148 | 168 | golden = trimGuids(golden); |
149 | 169 | const remoteState = trimGuids(await object._channel.debugScopeState()); |
|
0 commit comments