Skip to content
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

nyc is not working in combination with esm and ts-node #905

Closed
stevefan1999-personal opened this issue Aug 18, 2018 · 3 comments
Closed

Comments

@stevefan1999-personal
Copy link

Expected Behavior

Subprocess should load the typescript test file without problem

Observed Behavior

Test failed miserably, so that no coverage rates are computed:

PS <REDACTED> > yarn test:with-coverage
yarn run v1.9.4
$ nyc yarn test:start && nyc report
$ node -r esm -r ./.register.js ./alsatian.ts
ERROR LOADING FILE: E:/github/lerna-yarn-workspaces-example/packages/cli/src/__tests__/index.test.ts
<REDACTED>\packages\cli\src\__tests__\index.test.ts:1
(function (exports, require, module, __filename, __dirname) { import { AsyncTest, Expect, SpyOn, TestFixture } from 'alsatian'
                                                                     ^

SyntaxError: Unexpected token {
    at new Script (vm.js:73:7)
    at Object.<anonymous> (<REDACTED>\node_modules\esm\esm.js:1:211951)
    at Object.o._compile (<REDACTED>\node_modules\esm\esm.js:1:209188)
    at Object.replacementCompile (<REDACTED>\node_modules\nyc\node_modules\append-transform\index.js:58:13)
    at Object.replacementCompile (<REDACTED>\node_modules\nyc\node_modules\append-transform\index.js:58:13)
    at module.exports (<REDACTED>\node_modules\nyc\node_modules\default-require-extensions\js.js:8:9)
    at <REDACTED>\node_modules\nyc\node_modules\append-transform\index.js:62:4
    at <REDACTED>\node_modules\nyc\node_modules\append-transform\index.js:62:4
    at Object.<anonymous> (<REDACTED>\node_modules\nyc\node_modules\append-transform\index.js:62:4)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

=============================== Coverage summary ===============================
Statements   : Unknown% ( 0/0 )
Branches     : Unknown% ( 0/0 )
Functions    : Unknown% ( 0/0 )
Lines        : Unknown% ( 0/0 )
================================================================================
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Bonus Points! Code (or Repository) that Reproduces Issue

https://github.com/stevefan1999/lerna-yarn-workspaces-example

Forensic Information

Operating System: Microsoft Windows [Version 10.0.17134.165]
Environment Information:

Node: v10.9.0
NPM: 6.1.0

@stevefan1999-personal
Copy link
Author

Sooo it seems like the issue has been dormant for quite some time, but I do want to point out that upgrading esm and all the related dependencies to the latest version, it magically worked! I even had a chance to run the source with Istanbul, but sadly it's not perfect:

PS E:\github\lerna-yarn-workspaces-example> yarn test:with-coverage
yarn run v1.9.4
$ nyc yarn test:start && nyc report
$ node -r esm -r ./.register.js ./alsatian.ts
Transformation error for E:\github\lerna-yarn-workspaces-example\packages\core\src\index.ts ; return original code
An error occurred while trying to read the map file at E:\github\lerna-yarn-workspaces-example\packages\core\src\data:application\json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRTpcXGdpdGh1YlxcbGVybmEteWFybi13b3Jrc3BhY2VzLWV4YW1wbGVcXHBhY2thZ2VzXFxjb3JlXFxzcmNcXGluZGV4LnRzIiwic291cmNlcyI6WyJFOlxcZ2l0aHViXFxsZXJuYS15YXJuLXdvcmtzcGFjZXMtZXhhbXBsZVxccGFja2FnZXNcXGNvcmVcXHNyY1xcaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxVQUFVLFNBQVM7SUFDdkIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQTtBQUN0QixDQUFDO0FBRUQsT0FBTyxFQUFFLEdBQUcsSUFBSSxHQUFHLEVBQUUsTUFBTSxTQUFTLENBQUE7QUFDcEMsT0FBTyxFQUFFLE9BQU8sSUFBSSxHQUFHLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQSIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBhd2Vzb21lRm4oKTogdm9pZCB7XG4gIGNvbnNvbGUubG9nKCdIZWxsbycpXG59XG5cbmV4cG9ydCB7IGZvbyBhcyBhbnkgfSBmcm9tICcuL2lubmVyJ1xuZXhwb3J0IHsgZGVmYXVsdCBhcyBiYXIgfSBmcm9tICcuL2lubmVyMi9pbm5lcidcbiJdfQ==
Error: ENOENT: no such file or directory, open 'E:\github\lerna-yarn-workspaces-example\packages\core\src\data:application\json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRTpcXGdpdGh1YlxcbGVybmEteWFybi13b3Jrc3BhY2VzLWV4YW1wbGVcXHBhY2thZ2VzXFxjb3JlXFxzcmNcXGluZGV4LnRzIiwic291cmNlcyI6WyJFOlxcZ2l0aHViXFxsZXJuYS15YXJuLXdvcmtzcGFjZXMtZXhhbXBsZVxccGFja2FnZXNcXGNvcmVcXHNyY1xcaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxVQUFVLFNBQVM7SUFDdkIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQTtBQUN0QixDQUFDO0FBRUQsT0FBTyxFQUFFLEdBQUcsSUFBSSxHQUFHLEVBQUUsTUFBTSxTQUFTLENBQUE7QUFDcEMsT0FBTyxFQUFFLE9BQU8sSUFBSSxHQUFHLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQSIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBhd2Vzb21lRm4oKTogdm9pZCB7XG4gIGNvbnNvbGUubG9nKCdIZWxsbycpXG59XG5cbmV4cG9ydCB7IGZvbyBhcyBhbnkgfSBmcm9tICcuL2lubmVyJ1xuZXhwb3J0IHsgZGVmYXVsdCBhcyBiYXIgfSBmcm9tICcuL2lubmVyMi9pbm5lcidcbiJdfQ=='
Transformation error for E:\github\lerna-yarn-workspaces-example\packages\core\src\inner2\inner.ts ; return original code
An error occurred while trying to read the map file at E:\github\lerna-yarn-workspaces-example\packages\core\src\inner2\data:application\json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRTpcXGdpdGh1YlxcbGVybmEteWFybi13b3Jrc3BhY2VzLWV4YW1wbGVcXHBhY2thZ2VzXFxjb3JlXFxzcmNcXGlubmVyMlxcaW5uZXIudHMiLCJzb3VyY2VzIjpbIkU6XFxnaXRodWJcXGxlcm5hLXlhcm4td29ya3NwYWNlcy1leGFtcGxlXFxwYWNrYWdlc1xcY29yZVxcc3JjXFxpbm5lcjJcXGlubmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sQ0FBQyxPQUFPO0NBQVMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZGVmYXVsdCBjbGFzcyB7fVxuIl19
Error: ENOENT: no such file or directory, open 'E:\github\lerna-yarn-workspaces-example\packages\core\src\inner2\data:application\json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRTpcXGdpdGh1YlxcbGVybmEteWFybi13b3Jrc3BhY2VzLWV4YW1wbGVcXHBhY2thZ2VzXFxjb3JlXFxzcmNcXGlubmVyMlxcaW5uZXIudHMiLCJzb3VyY2VzIjpbIkU6XFxnaXRodWJcXGxlcm5hLXlhcm4td29ya3NwYWNlcy1leGFtcGxlXFxwYWNrYWdlc1xcY29yZVxcc3JjXFxpbm5lcjJcXGlubmVyLnRzIl0sIm5hbWCLI test
should log
|====================|

Pass: 2/2
Fail: 0/2
Ignore: 0/2
ERROR: Coverage for lines (0%) does not meet threshold (90%) for E:\github\lerna-yarn-workspaces-example\packages\cli\src\index.ts

=============================== Coverage summary ===============================
Statements   : 50% ( 2/4 )
Branches     : 100% ( 0/0 )
Functions    : 50% ( 1/2 )
Lines        : 50% ( 2/4 )
================================================================================

I'm using inline source map (original source incl.) so I think that's why the filename got somewhat verbose. Can someone dealing with similiar situations tell us how to workaround that?

@stale
Copy link

stale bot commented Jan 5, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 5, 2019
@stale stale bot removed the wontfix label Jan 5, 2019
@JaKXz
Copy link
Member

JaKXz commented Jan 5, 2019

@stevefan1999-personal sorry for the late reply, but I just tried out your repo and it seems to be working fine. Let me know if not and we can reopen this issue or look in some of the others to find similar problems.

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

No branches or pull requests

2 participants