mirror of
https://github.com/microsoft/playwright.git
synced 2024-10-26 21:33:38 +03:00
test(clock): fix clock mode bots (#31472)
This commit is contained in:
parent
93d147cf28
commit
f46ae15500
@ -85,16 +85,6 @@ export class Browser extends ChannelOwner<channels.BrowserChannel> implements ap
|
||||
const response = forReuse ? await this._channel.newContextForReuse(contextOptions) : await this._channel.newContext(contextOptions);
|
||||
const context = BrowserContext.from(response.context);
|
||||
await this._browserType._didCreateContext(context, contextOptions, this._options, options.logger || this._logger);
|
||||
if (!forReuse && process.env.PW_CLOCK === 'frozen') {
|
||||
await this._wrapApiCall(async () => {
|
||||
await context.clock.install({ time: 0 });
|
||||
await context.clock.pauseAt(1000);
|
||||
}, true);
|
||||
} else if (!forReuse && process.env.PW_CLOCK === 'realtime') {
|
||||
await this._wrapApiCall(async () => {
|
||||
await context.clock.install({ time: 0 });
|
||||
}, true);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
|
@ -274,6 +274,18 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
|
||||
contexts.set(context, contextData);
|
||||
if (captureVideo)
|
||||
context.on('page', page => contextData.pagesWithVideo.push(page));
|
||||
|
||||
if (process.env.PW_CLOCK === 'frozen') {
|
||||
await (context as any)._wrapApiCall(async () => {
|
||||
await context.clock.install({ time: 0 });
|
||||
await context.clock.pauseAt(1000);
|
||||
}, true);
|
||||
} else if (process.env.PW_CLOCK === 'realtime') {
|
||||
await (context as any)._wrapApiCall(async () => {
|
||||
await context.clock.install({ time: 0 });
|
||||
}, true);
|
||||
}
|
||||
|
||||
return context;
|
||||
});
|
||||
|
||||
|
@ -23,5 +23,5 @@ it('clock should be frozen', async ({ page }) => {
|
||||
|
||||
it('clock should be realtime', async ({ page }) => {
|
||||
it.skip(process.env.PW_CLOCK !== 'realtime');
|
||||
expect(await page.evaluate('Date.now()')).toBeLessThan(1000);
|
||||
expect(await page.evaluate('Date.now()')).toBeLessThan(10000);
|
||||
});
|
||||
|
@ -294,6 +294,7 @@ for (const useIntermediateMergeReport of [false] as const) {
|
||||
});
|
||||
|
||||
test('should include image diff when screenshot failed to generate due to animation', async ({ runInlineTest, page, showReport }) => {
|
||||
test.skip(process.env.PW_CLOCK === 'frozen', 'Assumes Date.now() changes');
|
||||
const result = await runInlineTest({
|
||||
'playwright.config.ts': `
|
||||
module.exports = { use: { viewport: { width: 200, height: 200 }} };
|
||||
|
Loading…
Reference in New Issue
Block a user