tsc-test
Testing TypeScript compilation (should succeed or should fail)
Basic usage
-
put
tsconfig.json
into test directory."noEmit"
is recommended. -
put files to be tested into test directory.
// should-succeed.tsWhen compilation errors should be occurred, write error code inline after 4 slashes(
////
).// should-fail-1.tsYou can write part of error message after error code. (with colon)
// should-fail-2.tsOr regular expression.
// should-fail-3.ts (but this code is not wrong acturally ...) -
run
tsc-test
command$ tsc-test -p test/tsconfig.json
And you will get output like below:
OK: test/should-fail-1.ts OK: test/should-fail-2.ts NG: test/should-fail-3.ts OK: test/should-succeed.ts test/should-fail-3.ts:6 expected: TS2339: /property .* does not exist/i bat was: <no error>
Run with test runner
ava
// runner.ts ;; ;tester.sources.forEach;
License
MIT