Skip to content

Commit f1a11c0

Browse files
committed
Fix another flaky tests
1 parent 1b40a4e commit f1a11c0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

programs/develop/webpack/plugin-extension/feature-scripts/__spec__/integration-public-path.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const fx = (demo: string) =>
88

99
async function waitForFile(
1010
filePath: string,
11-
timeoutMs: number = 2000,
11+
timeoutMs: number = 10000,
1212
intervalMs: number = 50
1313
) {
1414
const start = Date.now()

programs/develop/webpack/plugin-extension/feature-scripts/__spec__/integration.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ describe('ScriptsPlugin (integration)', () => {
2020
const fixturesPath = getFixturesPath('content')
2121
const outputPath = path.resolve(fixturesPath, 'dist', 'chrome')
2222

23+
async function waitForFile(
24+
filePath: string,
25+
timeoutMs: number = 10000,
26+
intervalMs: number = 50
27+
) {
28+
const start = Date.now()
29+
while (Date.now() - start < timeoutMs) {
30+
if (fs.existsSync(filePath)) return
31+
await new Promise((r) => setTimeout(r, intervalMs))
32+
}
33+
throw new Error(`File not found in time: ${filePath}`)
34+
}
35+
2336
beforeAll(async () => {
2437
await extensionBuild(fixturesPath, {browser: 'chrome'})
2538
})
@@ -32,6 +45,7 @@ describe('ScriptsPlugin (integration)', () => {
3245

3346
it('emits content script and background entries and wires CSS/assets', async () => {
3447
const manifestPath = path.join(outputPath, 'manifest.json')
48+
await waitForFile(manifestPath)
3549
const manifestText = await fs.promises.readFile(manifestPath, 'utf8')
3650
const manifest = JSON.parse(manifestText) as chrome.runtime.ManifestV3
3751

0 commit comments

Comments
 (0)