/espower-typescript

power-assert instrumentor for TypeScript

Primary LanguageTypeScript

espower-typescript

power-assert instrumentor for TypeScript

npm version Node.js Version Support build status Dependency Status License

TypeScript versions

  • espower-typescript v8.x uses TypeScript from v2.2 to v2.6
  • espower-typescript v7.x uses TypeScript v2.1
  • espower-typescript v6.x uses TypeScript v2.0
  • espower-typescript v5.x uses TypeScript v1.8
  • espower-typescript v4.x uses TypeScript v1.7
  • espower-typescript v2.x and v3.x uses TypeScript v1.6
  • espower-typescript v1.x uses TypeScript v1.5

Usage

Install

$ npm install -D espower-typescript power-assert mocha

Zero-config mode

// test/test.ts
import assert = require('assert');

describe('Array#join', () => {
  it('joins all elements into a string with separator', () => {
    assert(['a', 'b', 'c'].join(':') === 'a:b:c');
  });
});
// for mocha version >= 4
$ ./node_modules/.bin/mocha --require espower-typescript/guess "test/**/*.ts"


// for mocha version < 4 (deprecated)
$ ./node_modules/.bin/mocha --compilers ts:espower-typescript/guess "test/**/*.ts"

If your tests are not in test directory

You can set test directory in your package.json

{
    "name": "your-module",
    "description": "Your module",
    "version": "0.0.1",
    "directories": {
        "test": "spec/"
    },
...
}

Then, run mocha with --require espower-typescript/guess

// for mocha version >= 4
$ ./node_modules/.bin/mocha --require espower-typescript/guess "spec/**/*.ts"

// for mocha version < 4 (deprecated)
$ ./node_modules/.bin/mocha --compilers ts:espower-typescript/guess "spec/**/*.ts"

Note: 'espower-typescript/guess' is inspired by intelli-espower-loader

tsconfig.json and CompilerOptions

If tsconfig.json is in your prject root, 'espower-typescript/guess' loads it automatically.

Note: only compilerOptions field in tsconfig.json is applied.

JSX/React

.tsx files are supported.

License