1- espower-typescript
2- ====
1+ # espower-typescript
32
43> power-assert instrumentor for TypeScript
54
@@ -11,44 +10,57 @@ espower-typescript
1110
1211## TypeScript versions
1312
14- * espower-typescript v8.x uses TypeScript from v2.2 to v2.9
15- * espower-typescript v7.x uses TypeScript v2.1
16- * espower-typescript v6.x uses TypeScript v2.0
17- * espower-typescript v5.x uses TypeScript v1.8
18- * espower-typescript v4.x uses TypeScript v1.7
19- * espower-typescript v2.x and v3.x uses TypeScript v1.6
20- * espower-typescript v1.x uses TypeScript v1.5
13+ espower-typescript v9.x is compatible with TypeScript v2.4+
2114
22- ## Usage
15+ ## Usage (zero-config mode)
2316
24- ### Install
17+ NOTE: If you use older version than v9, see [ older document] ( https://github.com/power-assert-js/espower-typescript/blob/v8.1.3/README.md ) .
18+
19+ Install
2520
2621``` console
27- $ npm install -D espower-typescript power-assert mocha
22+ $ npm install -D espower-typescript power-assert mocha typescript @types/node @types/mocha
2823```
2924
30- ### Zero-config mode
25+ Create a test file (intensionally failed)
3126
3227``` typescript
3328// test/test.ts
3429import assert = require (' assert' );
3530
3631describe (' Array#join' , () => {
3732 it (' joins all elements into a string with separator' , () => {
38- assert ([' a' , ' b' , ' c' ].join (' :' ) === ' a:b:c' );
33+ assert ([' a' , ' b' , ' c' ].join (' :' ) === ' a:b:c: ' );
3934 });
4035});
4136```
4237
38+ Run test
39+
4340``` console
44- // for mocha version >= 4
4541$ ./node_modules/.bin/mocha --require espower-typescript/guess " test/**/*.ts"
42+ ```
43+
44+ Output
4645
46+ ```
47+ 1) Array#join
48+ joins all elements into a string with separator:
49+
50+ AssertionError [ERR_ASSERTION]: # test.ts:6
4751
48- // for mocha version < 4 (deprecated)
49- $ ./node_modules/.bin/mocha --compilers ts:espower-typescript/guess " test/**/*.ts"
52+ assert(['a','b','c'].join(':') === 'a:b:c:')
53+ | | |
54+ ["a","b","c"] "a:b:c" false
5055```
5156
57+ ### CAUTION: don't use ` import 'assert' from 'assert' `
58+
59+ Just use old style ` import 'assert' = require('assert') ` for assert module.
60+ This is limitation.
61+
62+ ## Configure
63+
5264### If your tests are not in ` test ` directory
5365
5466You can set test directory in your ` package.json `
@@ -68,36 +80,43 @@ You can set test directory in your `package.json`
6880Then, run mocha with ` --require espower-typescript/guess `
6981
7082``` console
71- // for mocha version >= 4
7283$ ./node_modules/.bin/mocha --require espower-typescript/guess " spec/**/*.ts"
73-
74- // for mocha version < 4 (deprecated)
75- $ ./node_modules/.bin/mocha --compilers ts:espower-typescript/guess " spec/**/*.ts"
7684```
7785
7886Note: ` 'espower-typescript/guess' ` is inspired by [ intelli-espower-loader] ( https://github.com/azu/intelli-espower-loader )
7987
80- ### tsconfig.json and CompilerOptions
88+ ### ts-node and ` tsconfig.json `
89+
90+ espower-typescript uses [ ts-node] ( https://github.com/TypeStrong/ts-node ) internally.
91+ It loads your [ tsconfig.json] ( https://github.com/Microsoft/TypeScript/wiki/tsconfig.json ) automatically.
92+
93+ ### Disable type check (transpile only)
8194
82- If [ tsconfig.json ] ( https://github.com/Microsoft/TypeScript/wiki/tsconfig.json ) is in your prject root, ` 'espower-typescript/guess' ` loads it automatically.
95+ Use ` TS_NODE_TRANSPILE_ONLY ` env of ts-node
8396
84- Note: only ` compilerOptions ` field in tsconfig.json is applied.
97+ ``` console
98+ $ TS_NODE_TRANSPILE_ONLY=1 ./node_modules/.bin/mocha --require espower-typescript/guess " test/**/*.ts"
99+ ```
85100
86101### JSX/React
87102
88103` .tsx ` files are supported.
89104
105+ ### ` allowJs `
106+
107+ If ` allowJs: true ` in your ` tsconfig.json ` , assertions in ` test/**/*.(js|jsx) ` are empowered.
108+
90109## License
91110
92- * MIT License: Teppei Sato
< ; [email protected] > ; 93- * Includes [ yosuke-furukawa/espower-traceur] ( https://github.com/yosuke-furukawa/espower-traceur )
94- * Includes [ azu/espower-babel] ( https://github.com/azu/espower-babel )
111+ - MIT License: Teppei Sato
< ; [email protected] > ; 112+ - Includes [ yosuke-furukawa/espower-traceur] ( https://github.com/yosuke-furukawa/espower-traceur )
113+ - Includes [ azu/espower-babel] ( https://github.com/azu/espower-babel )
95114
96115[ npm-image ] : https://img.shields.io/npm/v/espower-typescript.svg
97116[ npm-url ] : https://npmjs.org/package/espower-typescript
98117[ travis-image ] : https://travis-ci.org/power-assert-js/espower-typescript.svg?branch=master
99118[ travis-url ] : https://travis-ci.org/power-assert-js/espower-typescript
100119[ deps-image ] : https://david-dm.org/power-assert-js/espower-typescript.svg
101120[ deps-url ] : https://david-dm.org/power-assert-js/espower-typescript
102- [ node-version ] : https://img.shields.io/badge/Node.js%20support-v4, v6,v8-brightgreen.svg
121+ [ node-version ] : https://img.shields.io/badge/Node.js%20support-v6,v8,v10 -brightgreen.svg
103122[ license ] : https://img.shields.io/npm/l/espower-typescript.svg
0 commit comments