Skip to content

Commit

Permalink
updated mocha config to check whether to use --import or --loader
Browse files Browse the repository at this point in the history
  • Loading branch information
friedemannsommer committed Apr 19, 2024
1 parent dbb8326 commit 500e304
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .mocharc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const nodeVersion = process.version
const nodeMajorVersion = Number.parseInt(nodeVersion.slice(1, nodeVersion.indexOf('.')))

module.exports = {
'node-option': [process.version.startsWith('v16.') ? 'require=ts-node/register' : 'import=./node/register.mjs'],
'node-option': nodeMajorVersion > 16 ? ['import=./node/register.mjs'] : undefined,
extension: ['ts'],
spec: 'src/tests/**/*.spec.ts'
}
spec: 'src/tests/**/*.spec.ts',
loader: nodeMajorVersion <= 16 ? 'ts-node/esm' : undefined
}

0 comments on commit 500e304

Please sign in to comment.