Skip to content

Instantly share code, notes, and snippets.

@43081j
Last active February 1, 2024 16:06
Show Gist options
  • Save 43081j/78ce1392abb5043b02a29355006880a5 to your computer and use it in GitHub Desktop.
Save 43081j/78ce1392abb5043b02a29355006880a5 to your computer and use it in GitHub Desktop.
mocha 10 + chai 5 + ts-node
{
"loader": "ts-node/esm",
"extensions": ["ts"],
"spec": [
"tests/*.ts"
]
}
{
"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"
}
}
export const a = 5;
export const b = 6;
export const c = () => 7;
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);
});
});
{
"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"
]
}
@raphiecommerce
Copy link

Any idea why when I run this I get this error:

SyntaxError[ @/Users/johnsmac/bigproject/tests/system.spec.ts ]: Unexpected token '{'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment