Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

TypeScript 2.0 & ts-node 1.3 support #2

Open
drinchev opened this issue Sep 25, 2016 · 9 comments
Open

TypeScript 2.0 & ts-node 1.3 support #2

drinchev opened this issue Sep 25, 2016 · 9 comments

Comments

@drinchev
Copy link

Hey all,

Thank you for your hard work.

Just wanted to report that it doesn't work with TS 2.0 & ts-node 1.3. It actually compiles properly but the source maps doesn't seem to load in the coverage html file.

@drinchev
Copy link
Author

Update :

I ended up using https://github.com/istanbuljs/nyc

  "scripts": {
    "test:unit": "mocha --compilers ts:ts-node/register \"test/**/*.ts\"",
    "test": "nyc -e '.ts' --r html -r lcov -r text npm run test:unit",
    "build": "tsc"
  }

Credits for that goes to http://rundef.com/typescript-code-coverage-istanbul-nyc

@mummybot
Copy link

mummybot commented Mar 6, 2017

Pull request with upgraded package.json at #3

@Izhaki
Copy link
Owner

Izhaki commented Mar 6, 2017

This is a bit odd. I have a project that runs fine with typescript 2.0.3 and ts-node 1.4.3, albeit using jasmine.

So I suspect this issue can be resolved without nyc...

@drinchev do you have a project I can clone to see the error?

@mummybot
Copy link

mummybot commented Mar 6, 2017

FYI I didn't have the issue exactly as @drinchev stated, rather I hardly have any globally loaded node modules, and found the types setting in the example didn't reflect typescript 2+. Then using nyc (as the cmd line for Istanbul) it worked a treat.

@Izhaki
Copy link
Owner

Izhaki commented Mar 6, 2017

By the way @mummybot, thanks for the PR. Would be interesting to hear your thoughts on gotwarlost/istanbul#212 (comment)

@drinchev
Copy link
Author

drinchev commented Mar 7, 2017

@Izhaki unfortunately it would be hard to recreate the issue in a test project so late.

I think switching to nyc brings more benefits as well.

Thank you all!

@JimiC
Copy link

JimiC commented Mar 12, 2017

I wanted to add code coverage to an OSS I'm contributing that's written in Typescript. My first choice was istanbul, but having to also use remap-istanbul. to produce the desired result was a cons. Then I tried nyc and never looked back.

@Izhaki
Copy link
Owner

Izhaki commented Mar 12, 2017

So far, nyc prevails as the clear winner to this problem. That much I acknowledge. To be frank, although I'm yet to try it, I'm pretty sure I'll opt for it next based on the raving reviews.

I'm still trying to establish what is the relationship between Istanbul and nyc, and it is rather odd nobody seems to have an answer!

@sathya1972
Copy link

sathya1972 commented Mar 28, 2018

Thank you for all your effort!. I am newbie here. I am trying to run this as is, I get following error - when I execute npm run test:coverage. Is there anything I am missing here. Appreciate your help.

C:\POCs\Typescript-Mocha-Istanbul-Boilerplate-master\node_modules.bin_mocha.CMD:1
(function (exports, require, module, __filename, __dirname) { @if EXIST "%~dp0\node.exe" (
^

SyntaxError: Invalid or unexpected token
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at runFn (C:\POCs\Typescript-Mocha-Istanbul-Boilerplate-master\node_modules\istanbul\lib\command\cover.js:126:16)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants