Skip to content

Commit 7774a0f

Browse files
committed
test: fix flaky tests
1 parent 5b184fa commit 7774a0f

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

bin/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ configure({
2626
files: ['tests/**/*.spec.ts'],
2727
plugins: [assert(), runFailedTests(), fileSystem({ basePath: TEST_TMP_DIR_PATH })],
2828
reporters: [specReporter()],
29-
timeout: 10 * 1000,
29+
timeout: 5 * 1000,
3030
importer: (filePath: string) => import(pathToFileURL(filePath).href),
3131
},
3232
})

tests/watch.spec.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ test.group('Watcher', () => {
3131
done()
3232
})
3333

34-
await fs.create('bar.ts', '')
34+
output!.watcher.on('watcher:ready', async () => {
35+
await fs.create('bar.ts', '')
36+
})
3537
})
3638
.waitForDone()
3739
.skip(!!process.env.CI, 'Skipping in CI. Cannot get chokidar to work')
@@ -55,7 +57,9 @@ test.group('Watcher', () => {
5557
done()
5658
})
5759

58-
await fs.create('foo.ts', 'hello world')
60+
output!.watcher.on('watcher:ready', async () => {
61+
await fs.create('foo.ts', 'hello world')
62+
})
5963
})
6064
.waitForDone()
6165
.skip(!!process.env.CI, 'Skipping in CI. Cannot get chokidar to work')
@@ -79,7 +83,9 @@ test.group('Watcher', () => {
7983
done()
8084
})
8185

82-
await fs.remove('foo.ts')
86+
output!.watcher.on('watcher:ready', async () => {
87+
await fs.remove('foo.ts')
88+
})
8389
})
8490
.waitForDone()
8591
.skip(!!process.env.CI, 'Skipping in CI. Cannot get chokidar to work')
@@ -105,7 +111,9 @@ test.group('Watcher', () => {
105111
assert.fail('Never expected to reach here')
106112
})
107113

108-
await fs.create('baz.ts', '')
114+
output!.watcher.on('watcher:ready', async () => {
115+
await fs.create('baz.ts', '')
116+
})
109117
await new Promise((resolve) => setTimeout(resolve, 1000))
110118
}).skip(!!process.env.CI, 'Skipping in CI. Cannot get chokidar to work')
111119

@@ -132,7 +140,9 @@ test.group('Watcher', () => {
132140
done()
133141
})
134142

135-
await fs.create('foo.md', '')
143+
output!.watcher.on('watcher:ready', async () => {
144+
await fs.create('foo.md', '')
145+
})
136146
})
137147
.waitForDone()
138148
.skip(!!process.env.CI, 'Skipping in CI. Cannot get chokidar to work')

0 commit comments

Comments
 (0)