remap istanbul when using typescript AND babel

402 Views Asked by At

I'm trying to use remap istanbul to get code coverage for my TypeScript project. However, because I'm using async/await and TypeScript doesn't yet support transpiling that code to ES5 I'm also using Babel to make that work. So basically my typescript code is transpiled by the TypeScript compiler to ES6 which is then transpiled to ES5 using Babel.

Now when I try to generate a coverage report it fails to load the JavaScript file that is generated by TypeScript because that file is never created (since I'm using gulp and I'm piping it straight through). What would be the best way to set this up?

1

There are 1 best solutions below

0
On

Only Istanbul 1.x does it well.

From this repository:

{
  "name": "sample-babel-node",
  "version": "1.0.0",
  "description": "Sample project to demonstrate source mapped coverage reports with istanbul",
  "main": "index.js",
  "directories": {
    "test": "test"
  },
  "scripts": {
    "test": "babel-node ./node_modules/istanbul/lib/cli.js cover ./test/index.test.js"
  },
  "repository": {
    "type": "git",
    "url": "git+ssh://[email protected]/istanbuljs/sample-babel-node.git"
  },
  "author": "",
  "license": "BSD-3-Clause",
  "bugs": {
    "url": "https://github.com/istanbuljs/sample-babel-node/issues"
  },
  "homepage": "https://github.com/istanbuljs/sample-babel-node#readme",
  "dependencies": {
    "babel-cli": "^6.2.0",
    "babel-preset-es2015": "^6.1.18"
  },
  "devDependencies": {
    "istanbul": "^1.0.0-alpha.2"
  }
}

Also checkout this git issue, there's more there (gulp, grunt, etc.).