Skip to content

Commit d776105

Browse files
committed
Using ts-node and tsconfig-paths to run mocha over Typescript test files
1 parent 8ca88db commit d776105

7 files changed

+10
-91
lines changed

docs/in-depth/testing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ In `package.json`, add a new `test-integration` script and add the new integrati
6161
```json
6262
"scripts": {
6363
"test": "npm run test-unit && npm run test-integration",
64-
"test-integration": "npm run build && rollup -c rollup.test-integration-config.js && mocha dist/test-integration.bundle.js",
64+
"test-integration": "npm run build && TS_NODE_PROJECT='./tsconfig.test.json' mocha ./test/integration/**/*.ts",
6565
}
6666
```
6767

package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"push-pserver": "rollup -c --environment DEST:pserver",
1212
"push-sim": "rollup -c --environment DEST:sim",
1313
"test": "npm run test-unit",
14-
"test-unit": "rollup -c rollup.test-unit-config.js && mocha dist/test-unit.bundle.js",
14+
"test-unit": "TS_NODE_PROJECT='./tsconfig.test.json' mocha test/unit/**/*.ts",
1515
"test-integration": "echo 'See docs/in-depth/testing.md for instructions on enabling integration tests'",
1616
"watch-main": "rollup -cw --environment DEST:main",
1717
"watch-pserver": "rollup -cw --environment DEST:pserver",
@@ -32,7 +32,6 @@
3232
},
3333
"devDependencies": {
3434
"@rollup/plugin-commonjs": "^11.1.0",
35-
"@rollup/plugin-multi-entry": "^3.0.0",
3635
"@rollup/plugin-node-resolve": "^7.1.3",
3736
"@types/chai": "^4.1.6",
3837
"@types/lodash": "3.10.2",
@@ -54,14 +53,13 @@
5453
"mocha": "^5.2.0",
5554
"prettier": "^2.0.4",
5655
"rollup": "^2.6.1",
57-
"rollup-plugin-buble": "^0.19.8",
5856
"rollup-plugin-clear": "^2.0.7",
59-
"rollup-plugin-nodent": "^0.2.2",
6057
"rollup-plugin-screeps": "^1.0.0",
6158
"rollup-plugin-typescript2": "^0.27.0",
6259
"sinon": "^6.3.5",
6360
"sinon-chai": "^3.2.0",
6461
"ts-node": "^8.8.2",
62+
"tsconfig-paths": "^3.9.0",
6563
"typescript": "^3.8.3"
6664
},
6765
"dependencies": {

rollup.test-integration-config.js

-34
This file was deleted.

rollup.test-unit-config.js

-32
This file was deleted.

test/mocha.opts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
--require test/setup-node.js
22
--require ts-node/register
3+
--require tsconfig-paths/register
34
--ui bdd
45

56
--reporter spec

tsconfig.test-integration.json

-20
This file was deleted.

tsconfig.test.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "CommonJs"
5+
}
6+
}

0 commit comments

Comments
 (0)