Skip to content

Commit

Permalink
fix: flaky fs test
Browse files Browse the repository at this point in the history
Reported by aws#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.

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

Signed-off-by: nkomonen <[email protected]>
  • Loading branch information
nkomonen-amazon committed Feb 5, 2024
1 parent 819e63a commit fcef50f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/test/srcShared/fs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,15 @@ describe('FileSystem', function () {

describe('mkdir()', function () {
const paths = ['a', 'a/b', 'a/b/c', 'a/b/c/d/']
let dirPath: string // store path for easy cleanup

afterEach(async function () {
await fsCommon.delete(dirPath)
})

paths.forEach(async function (p) {
it(`creates folder: '${p}'`, async function () {
const dirPath = createTestPath(p)
dirPath = createTestPath(p)
await fsCommon.mkdir(dirPath)
assert.ok(existsSync(dirPath))
})
Expand All @@ -169,12 +174,12 @@ describe('FileSystem', function () {
it(`creates folder but uses the "fs" module if in C9: '${p}'`, async function () {
sandbox.stub(extensionUtilities, 'isCloud9').returns(true)
const mkdirSpy = sandbox.spy(fsPromises, 'mkdir')
const dirPath = createTestPath(p)
dirPath = createTestPath(p)

await fsCommon.mkdir(dirPath)

assert.ok(existsSync(dirPath))
assert.ok(mkdirSpy.calledOnce)
assert.strictEqual(mkdirSpy.callCount, 1)
})
})
})
Expand Down

0 comments on commit fcef50f

Please sign in to comment.