Last active
February 1, 2024 16:06
-
-
Save 43081j/78ce1392abb5043b02a29355006880a5 to your computer and use it in GitHub Desktop.
mocha 10 + chai 5 + ts-node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"loader": "ts-node/esm", | |
"extensions": ["ts"], | |
"spec": [ | |
"tests/*.ts" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "temp-chai", | |
"version": "1.0.0", | |
"type": "module", | |
"main": "lib/main.js", | |
"scripts": { | |
"test": "mocha" | |
}, | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"@types/chai": "^4.3.11", | |
"@types/mocha": "^10.0.6", | |
"chai": "^5.0.0", | |
"mocha": "^10.2.0", | |
"ts-node": "^10.9.2", | |
"typescript": "^5.3.3" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const a = 5; | |
export const b = 6; | |
export const c = () => 7; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {expect} from 'chai'; | |
import * as main from '../src/main.js'; | |
describe('main', () => { | |
it('should export things', () => { | |
expect(main.a).to.equal(5); | |
expect(main.b).to.equal(6); | |
expect(main.c()).to.equal(7); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
"outDir": "./lib", | |
"sourceMap": true, | |
"module": "nodenext", | |
"moduleResolution": "nodenext", | |
"target": "esnext", | |
"forceConsistentCasingInFileNames": true, | |
"noImplicitReturns": true, | |
"noUnusedLocals": true, | |
"noUnusedParameters": true, | |
"noFallthroughCasesInSwitch": true, | |
"strict": true | |
}, | |
"include": [ | |
"src/**/*.ts" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any idea why when I run this I get this error:
SyntaxError[ @/Users/johnsmac/bigproject/tests/system.spec.ts ]: Unexpected token '{'