-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent infinite loop on prettyDOM calls (#7250)
- Loading branch information
Showing
7 changed files
with
101 additions
and
1 deletion.
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
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,12 @@ | ||
import { commands } from '@vitest/browser/context' | ||
import { it } from 'vitest' | ||
|
||
declare module '@vitest/browser/context' { | ||
interface BrowserCommands { | ||
forceCrash: () => Promise<void> | ||
} | ||
} | ||
|
||
it('fails gracefully when browser crashes', async () => { | ||
await commands.forceCrash() | ||
}) |
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,39 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import { defineConfig } from 'vitest/config' | ||
import { instances, provider } from '../../settings' | ||
import { BrowserCommand } from 'vitest/node' | ||
|
||
const forceCrash: BrowserCommand<[]> = async (context) => { | ||
const browser = context.context.browser().browserType().name() | ||
if (browser === 'chromium') { | ||
await context.page.goto('chrome://crash') | ||
} | ||
|
||
if (browser === 'firefox') { | ||
await context.page.goto('about:crashcontent') | ||
} | ||
|
||
throw new Error(`Browser crash not supported for ${browser}`) | ||
} | ||
|
||
export default defineConfig({ | ||
cacheDir: fileURLToPath(new URL("./node_modules/.vite", import.meta.url)), | ||
test: { | ||
browser: { | ||
commands: { forceCrash }, | ||
enabled: true, | ||
provider, | ||
instances: instances.map(instance => ({ | ||
...instance, | ||
context: { | ||
actionTimeout: 500, | ||
}, | ||
})), | ||
}, | ||
expect: { | ||
poll: { | ||
timeout: 500, | ||
}, | ||
}, | ||
}, | ||
}) |
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,17 @@ | ||
import { expect, test } from 'vitest' | ||
import { instances, provider, runBrowserTests } from './utils' | ||
|
||
// TODO handle webdriverio. Currently they | ||
// expose no trustable way to detect browser crashes. | ||
test.runIf(provider === 'playwright')('fails gracefully when browser crashes', async () => { | ||
const { stderr } = await runBrowserTests({ | ||
root: './fixtures/browser-crash', | ||
reporters: [['verbose', { isTTY: false }]], | ||
browser: { | ||
// webkit has no support for simulating browser crash | ||
instances: instances.filter(item => item.name !== 'webkit'), | ||
}, | ||
}) | ||
|
||
expect(stderr).contains('Page crashed when executing tests') | ||
}) |
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