New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always result in unknown coverage report when using nyc #37

Closed
ruiming opened this Issue Sep 18, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@ruiming

ruiming commented Sep 18, 2017

After writing test, I use below two script to start my test:

"test1": "nyc mocha --compilers ts:espower-typescript/guess 'test/*.ts' --require source-map-support/register --timeout=10000",
"test2": "nyc mocha --require ts-node/register 'test/*.ts' --require source-map-support/register --timeout=10000"

My test file did not includes power-assert in order to make test2 works.

Both of the two script works well with all test passed. However, test1 will always result in unknown coverage report while test2 work as expected with generating correct coverage report.

@teppeis

This comment has been minimized.

Contributor

teppeis commented Sep 18, 2017

@ruiming Can I see your repo?

@ruiming

This comment has been minimized.

ruiming commented Sep 18, 2017

@Narazaka

This comment has been minimized.

Narazaka commented Oct 14, 2017

@teppeis I also have same problem at https://github.com/Narazaka/routes-generator.js/tree/nyc (nyc branch).

It seems to be problem of path resolving.

nyc mocha succeeds in both --compilers ts:ts-node-register and --compilers ts:espower-typescript/guess, but in the latter, coverage html says "no such file or directory, open 'D:\make\devel\lib\routes-generator.ts'" and lcov.info says SF:D:\make\devel\lib\routes-generator.ts.
The real path is not D:\make\devel\lib\routes-generator.ts but D:\make\devel\routes-generator\lib\routes-generator.ts.
espower-typescript seems to make project root path '/path/to/project' to '/path/to'.

The full error in html:

Unable to lookup source: D:\make\devel\lib\routes-generator.ts(ENOENT: no such file or directory, open 'D:\make\devel\lib\routes-generator.ts') Error: Unable to lookup source: D:\make\devel\lib\routes-generator.ts(ENOENT: no such file or directory, open 'D:\make\devel\lib\routes-generator.ts') at Context.defaultSourceLookup [as sourceFinder] (D:\make\devel\routes-generator\node_modules\nyc\node_modules\istanbul-lib-report\lib\context.js:15:15) at Context.getSource (D:\make\devel\routes-generator\node_modules\nyc\node_modules\istanbul-lib-report\lib\context.js:74:17) at Object.annotateSourceCode (D:\make\devel\routes-generator\node_modules\nyc\node_modules\istanbul-reports\lib\html\annotator.js:172:38) at HtmlReport.onDetail (D:\make\devel\routes-generator\node_modules\nyc\node_modules\istanbul-reports\lib\html\index.js:217:39) at Visitor.(anonymous function) [as onDetail] (D:\make\devel\routes-generator\node_modules\nyc\node_modules\istanbul-lib-report\lib\tree.js:34:30) at ReportNode.Node.visit (D:\make\devel\routes-generator\node_modules\nyc\node_modules\istanbul-lib-report\lib\tree.js:123:17) at D:\make\devel\routes-generator\node_modules\nyc\node_modules\istanbul-lib-report\lib\tree.js:116:23 at Array.forEach (native) at visitChildren (D:\make\devel\routes-generator\node_modules\nyc\node_modules\istanbul-lib-report\lib\tree.js:115:32) at ReportNode.Node.visit (D:\make\devel\routes-generator\node_modules\nyc\node_modules\istanbul-lib-report\lib\tree.js:126:5)

@ruiming

This comment has been minimized.

ruiming commented Nov 6, 2017

Fixed by adding sourceRoot option to compilerOptions in tsconfig.json.

power-assert-js/power-assert#92

@ruiming ruiming closed this Nov 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment