test: unflake electron tests (#29520)

This commit is contained in:
Max Schmitt 2024-02-15 22:09:17 +01:00 committed by GitHub
parent dc9cddde95
commit 05e6b5b5c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 7 deletions

View file

@ -29,10 +29,11 @@ test('should fire close event via ElectronApplication.close();', async ({ launch
await electronApp.close();
// Close one more time - this should be a noop.
await electronApp.close();
expect(events.join('|')).toBe('process(exit)|context(close)|application(close)');
events.sort(); // we don't care about the order
expect(events).toEqual(['application(close)', 'context(close)', 'process(exit)']);
// Give it some time to fire more events - there should not be any.
await new Promise(f => setTimeout(f, 1000));
expect(events.join('|')).toBe('process(exit)|context(close)|application(close)');
expect(events).toEqual(['application(close)', 'context(close)', 'process(exit)']);
});
test('should fire close event via BrowserContext.close()', async ({ launchElectronApp }) => {
@ -44,10 +45,11 @@ test('should fire close event via BrowserContext.close()', async ({ launchElectr
await electronApp.context().close();
// Close one more time - this should be a noop.
await electronApp.context().close();
expect(events.join('|')).toBe('process(exit)|context(close)|application(close)');
events.sort(); // we don't care about the order
expect(events).toEqual(['application(close)', 'context(close)', 'process(exit)']);
// Give it some time to fire more events - there should not be any.
await new Promise(f => setTimeout(f, 1000));
expect(events.join('|')).toBe('process(exit)|context(close)|application(close)');
expect(events).toEqual(['application(close)', 'context(close)', 'process(exit)']);
});
test('should fire close event when the app quits itself', async ({ launchElectronApp }) => {
@ -61,10 +63,11 @@ test('should fire close event when the app quits itself', async ({ launchElectro
await electronApp.evaluate(({ app }) => app.quit());
await waitForAppClose;
}
expect(events.join('|')).toBe('process(exit)|context(close)|application(close)');
events.sort(); // we don't care about the order
expect(events).toEqual(['application(close)', 'context(close)', 'process(exit)']);
// Give it some time to fire more events - there should not be any.
await new Promise(f => setTimeout(f, 1000));
expect(events.join('|')).toBe('process(exit)|context(close)|application(close)');
expect(events).toEqual(['application(close)', 'context(close)', 'process(exit)']);
});
test('should fire console events', async ({ launchElectronApp }) => {

View file

@ -18,7 +18,7 @@ import assert from 'assert';
import { spawnAsync } from '../../packages/playwright-core/lib/utils/spawnAsync';
export default async () => {
const result = await spawnAsync('npx', ['electron', require.resolve('./electron-print-chromium-version.js')], {
const result = await spawnAsync('npx', ['electron', require.resolve('./electron-print-chromium-version.js'), '--no-sandbox'], {
shell: true,
});
const chromiumVersion = result.stdout.trim();