Skip to content

Commit 6982bcc

Browse files
fix: flaky fs test (#4391)
Reported by #4390, this test is failing on the mkdirSpy call count assertion. Not exactly sure why this is flaky, but maybe it is due to the previous folders not being cleaned up. ## Solution This commit deletes the created folders after each test finishes. Additionally, this commit checks the actual spy call count so that we can better debug the issue <!--- REMINDER: - Read CONTRIBUTING.md first. - Add test coverage for your changes. - Update the changelog using `npm run newChange`. - Link to related issues/commits. - Testing: how did you test your changes? - Screenshots --> ## License By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. Signed-off-by: nkomonen <[email protected]>
1 parent cbac86f commit 6982bcc

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/toolkit/src/test/srcShared/fs.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('FileSystem', function () {
2424

2525
before(async function () {
2626
fakeContext = await FakeExtensionContext.create()
27+
await deleteTestRoot() // incase a previous test run failed to clean
2728
})
2829

2930
beforeEach(async function () {
@@ -161,7 +162,7 @@ describe('FileSystem', function () {
161162
it(`creates folder: '${p}'`, async function () {
162163
const dirPath = createTestPath(p)
163164
await fsCommon.mkdir(dirPath)
164-
assert.ok(existsSync(dirPath))
165+
assert(existsSync(dirPath))
165166
})
166167
})
167168

@@ -173,8 +174,8 @@ describe('FileSystem', function () {
173174

174175
await fsCommon.mkdir(dirPath)
175176

176-
assert.ok(existsSync(dirPath))
177-
assert.ok(mkdirSpy.calledOnce)
177+
assert(existsSync(dirPath))
178+
assert.strictEqual(mkdirSpy.callCount, 1)
178179
})
179180
})
180181
})
@@ -300,14 +301,14 @@ describe('FileSystem', function () {
300301
}
301302

302303
function testRootPath() {
303-
return path.join(fakeContext.globalStorageUri.fsPath, 'testDir')
304+
return path.join(fakeContext.globalStorageUri.fsPath, 'fsTestDir')
304305
}
305306

306307
async function makeTestRoot() {
307308
return mkdirSync(testRootPath())
308309
}
309310

310311
async function deleteTestRoot() {
311-
return rmSync(testRootPath(), { recursive: true })
312+
rmSync(testRootPath(), { recursive: true, force: true })
312313
}
313314
})

0 commit comments

Comments
 (0)