Created
May 10, 2021 13:51
-
-
Save lorenzofox3/81c201346b28239b477643b1119bbbe9 to your computer and use it in GitHub Desktop.
ts-setup-example
ts-setup-example
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": "zora-coverage", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "ts-node sum.spec.ts", | |
"test:only": "RUN_ONLY=true ts-node sum.spec.ts", | |
"test:coverage": "c8 --exclude to-be-excluded.ts ts-node sum.spec.ts", | |
"dev": "nodemon sum.spec.ts" | |
}, | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"c8": "~7.7.2", | |
"nodemon": "~2.0.7", | |
"ts-node": "~9.1.1", | |
"zora": "^4.1.0" | |
} | |
} |
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 {test} from 'zora'; | |
import sum from './sum' | |
test(`sum`, (t) =>{ | |
t.eq(sum(0,4), 4); | |
}) |
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 {foo} from './to-be-excluded'; | |
foo(); | |
export default (a: number, b: number): number => a + b; |
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 foo = () => { | |
console.log(foo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've had no luck with this.
I use
esbuild
, which requires"type": "module"
, and this won't work with that. (the same issue probably affects other bundlers that rely ontype
- likeparcel
ormicrobundle
...)I also tried the experimental ESM feature in
ts-node
- sonode --loader ts-node/esm
instead ofts-node
, that doesn't work either, just errors at the firstimport
orexport
statement.I had more luck with this approach in
zora-recipes
:https://github.com/lorenzofox3/zora-recipes/blob/master/3_node_typescript/package.json
Still, no luck with
c8
and code-coverage though. (will post more on that here.)