Skip to content

Commit

Permalink
chore: fix cleanup for copy-template-dir test
Browse files Browse the repository at this point in the history
  • Loading branch information
khendrikse committed Nov 25, 2024
1 parent 125c99d commit 41d5001
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions tests/unit/utils/copy-template-dir/copy-template-dir.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ describe('copyTemplateDir', () => {
checkCreatedFileNames(files.map((file) => file.path))

// Cleanup
fs.rmdirSync(outDir, { recursive: true })
try {
await fs.rm(outDir, { recursive: true, force: true })
} catch (error) {
console.error(`Cleanup failed: ${error.message}`)
}
})

test('should inject context variables strings', async () => {
Expand All @@ -61,7 +65,11 @@ describe('copyTemplateDir', () => {
expect(fileContent).toBe('hello bar sama')

// Cleanup
fs.rmdirSync(outDir, { recursive: true })
try {
await fs.rm(outDir, { recursive: true, force: true })
} catch (error) {
console.error(`Cleanup failed: ${error.message}`)
}
})

test('should inject context variables strings into filenames', async () => {
Expand All @@ -73,7 +81,11 @@ describe('copyTemplateDir', () => {
expect(fs.existsSync(path.join(outDir, 'bar.txt'))).toBe(true)

// Cleanup
fs.rmdirSync(outDir, { recursive: true })
try {
await fs.rm(outDir, { recursive: true, force: true })
} catch (error) {
console.error(`Cleanup failed: ${error.message}`)
}
})

test('should inject context variables strings into directory names', async () => {
Expand All @@ -85,6 +97,10 @@ describe('copyTemplateDir', () => {
expect(fs.existsSync(path.join(outDir, 'bar'))).toBe(true)

// Cleanup
fs.rmdirSync(outDir, { recursive: true })
try {
await fs.rm(outDir, { recursive: true, force: true })
} catch (error) {
console.error(`Cleanup failed: ${error.message}`)
}
})
})

0 comments on commit 41d5001

Please sign in to comment.