Skip to content

Commit ae87882

Browse files
committed
fix(tests): resolve CI failures on Windows and formatting issues
- Convert esm-imports.test.mjs to vitest (was using node:test API) - Fix formatting in esm-imports test (multi-line assert.ok) - Replace fs.rm with safeDelete in json tests for Windows compatibility - Fixes EPERM errors when cleaning up temp directories on Windows - Uses @socketsecurity/lib/fs safeDelete for cross-platform safety
1 parent 54bb9b0 commit ae87882

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

test/integration/esm-imports.test.mjs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,36 @@
44
* esbuild-compiled CommonJS modules.
55
*/
66

7-
import { describe, it } from 'node:test'
8-
import assert from 'node:assert'
7+
import { describe, expect, it } from 'vitest'
98

109
describe('ESM imports from CommonJS', () => {
1110
describe('globs module', () => {
1211
it('should import glob function', async () => {
1312
const { glob } = await import('@socketsecurity/lib/globs')
14-
assert.strictEqual(typeof glob, 'function', 'glob should be a function')
13+
expect(typeof glob).toBe('function')
1514
})
1615

1716
it('should import globSync function', async () => {
1817
const { globSync } = await import('@socketsecurity/lib/globs')
19-
assert.strictEqual(
20-
typeof globSync,
21-
'function',
22-
'globSync should be a function',
23-
)
18+
expect(typeof globSync).toBe('function')
2419
})
2520

2621
it('should import defaultIgnore', async () => {
2722
const { defaultIgnore } = await import('@socketsecurity/lib/globs')
28-
assert.ok(Array.isArray(defaultIgnore), 'defaultIgnore should be an array')
23+
expect(Array.isArray(defaultIgnore)).toBe(true)
2924
})
3025

3126
it('should import getGlobMatcher', async () => {
3227
const { getGlobMatcher } = await import('@socketsecurity/lib/globs')
33-
assert.strictEqual(
34-
typeof getGlobMatcher,
35-
'function',
36-
'getGlobMatcher should be a function',
37-
)
28+
expect(typeof getGlobMatcher).toBe('function')
3829
})
3930

4031
it('should import all exports together', async () => {
4132
const module = await import('@socketsecurity/lib/globs')
42-
assert.strictEqual(typeof module.glob, 'function')
43-
assert.strictEqual(typeof module.globSync, 'function')
44-
assert.strictEqual(typeof module.getGlobMatcher, 'function')
45-
assert.ok(Array.isArray(module.defaultIgnore))
33+
expect(typeof module.glob).toBe('function')
34+
expect(typeof module.globSync).toBe('function')
35+
expect(typeof module.getGlobMatcher).toBe('function')
36+
expect(Array.isArray(module.defaultIgnore)).toBe(true)
4637
})
4738
})
4839
})

test/unit/json.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,9 @@ describe('json', () => {
754754
describe('EditableJson', () => {
755755
const { tmpdir } = require('node:os')
756756
const { join } = require('node:path')
757-
const { mkdtemp, readFile, rm, writeFile } = require('node:fs/promises')
757+
const { mkdtemp, readFile, writeFile } = require('node:fs/promises')
758+
const { safeDelete } =
759+
require('@socketsecurity/lib/fs') as typeof import('@socketsecurity/lib/fs')
758760
const { getEditableJsonClass } =
759761
require('@socketsecurity/lib/json/edit') as typeof import('@socketsecurity/lib/json/edit')
760762

@@ -766,7 +768,7 @@ describe('json', () => {
766768

767769
afterEach(async () => {
768770
if (testDir) {
769-
await rm(testDir, { recursive: true, force: true })
771+
await safeDelete(testDir)
770772
}
771773
})
772774

0 commit comments

Comments
 (0)