Skip to content

Commit 82938f1

Browse files
committed
fix(test): resolve test runner issues and type errors
- Fix rootPath resolution in test runner (scripts/ -> project root) - Fix TypeScript errors in maintained-node-versions immutability tests - Refactor validation scripts for cleaner imports and error handling
1 parent 20943ef commit 82938f1

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

scripts/test/main.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ process.on('unhandledRejection', (reason, _promise) => {
3737
})
3838

3939
const __dirname = path.dirname(fileURLToPath(import.meta.url))
40-
const rootPath = path.resolve(__dirname, '..')
40+
const rootPath = path.resolve(__dirname, '../..')
4141
const nodeModulesBinPath = path.join(rootPath, 'node_modules', '.bin')
4242

4343
const tsconfigPath = '.config/tsconfig.check.json'

scripts/validate/external-esm-cjs.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
import { createRequire } from 'node:module'
1515
import { readdirSync } from 'node:fs'
1616
import path from 'node:path'
17-
import { fileURLToPath } from 'node:url'
18-
import { pathToFileURL } from 'node:url'
17+
import { fileURLToPath, pathToFileURL } from 'node:url'
1918

2019
const __dirname = path.dirname(fileURLToPath(import.meta.url))
2120
const externalDir = path.resolve(__dirname, '..', '..', 'dist', 'external')
@@ -46,7 +45,7 @@ function getJsFilesRecursive(dir, files = []) {
4645
getJsFilesRecursive(fullPath, files)
4746
}
4847
}
49-
} catch (_error) {
48+
} catch {
5049
// Directory might not be accessible
5150
}
5251

scripts/validate/external-exports.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function getExternalModules(dir) {
5353
}
5454
}
5555
}
56-
} catch (_error) {
56+
} catch {
5757
// External directory might not exist in some build states
5858
return []
5959
}

test/unit/maintained-node-versions.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,33 @@ describe('maintained-node-versions', () => {
111111
describe('immutability', () => {
112112
it('should not allow modification of array elements', () => {
113113
expect(() => {
114-
maintainedNodeVersions[0] = '99.99.99'
114+
// Testing runtime immutability (readonly array)
115+
const arr = maintainedNodeVersions as any
116+
arr[0] = '99.99.99'
115117
}).toThrow()
116118
})
117119

118120
it('should not allow push', () => {
119121
expect(() => {
120-
maintainedNodeVersions.push('99.99.99')
122+
// Testing runtime immutability (readonly array)
123+
const arr = maintainedNodeVersions as any
124+
arr.push('99.99.99')
121125
}).toThrow()
122126
})
123127

124128
it('should not allow pop', () => {
125129
expect(() => {
126-
maintainedNodeVersions.pop()
130+
// Testing runtime immutability (readonly array)
131+
const arr = maintainedNodeVersions as any
132+
arr.pop()
127133
}).toThrow()
128134
})
129135

130136
it('should not allow modification of named properties', () => {
131137
expect(() => {
132-
maintainedNodeVersions.current = '99.99.99'
138+
// Testing runtime immutability (readonly properties)
139+
const obj = maintainedNodeVersions as any
140+
obj.current = '99.99.99'
133141
}).toThrow()
134142
})
135143
})

0 commit comments

Comments
 (0)