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

Including all files when not using require or register #776

Closed
cdibbs opened this issue Feb 10, 2018 · 3 comments
Closed

Including all files when not using require or register #776

cdibbs opened this issue Feb 10, 2018 · 3 comments

Comments

@cdibbs
Copy link

cdibbs commented Feb 10, 2018

Expected Behavior

When running a lesser-known testing framework (called Alsatian) with nyc and ts-node, there should be an option to cover all files, despite the absence of a require definition in the config.

Observed Behavior

Coverage seems correct, in terms of individual files, but the results don't include files not directly imported by the tests. My understanding of "all": true that I've gleaned from issues and docs scattered about is that it won't actually include all files without a require. If I try to require ts-node/register with nyc (again, despite it seeming to work, coverage-wise, without that), then all desired files are included, but coverage becomes nonsense, highlighting random byte ranges.

Bonus Points! Code (or Repository) that Reproduces Issue

package.json and runner.ts

  "scripts": {
    "precover": "rimraf ./coverage/*",
    "cover": "nyc npm run unittest",
    "unittest": "ts-node --project tsconfig-xunit.json src/spec-lib/runner.ts"    
  },
  "nyc": {
    "include": [
      "src/lib/**"
    ],
    "extension": [
      ".ts"
    ],
    "exclude": [
      "typings",
      "**/*.d.ts",
      "**/*.test.ts",
      "**/*.spec.ts"
    ],
    "reporter": [
      "json",
      "html"
    ],
    "all": true
  }

Forensic Information

Operating System: the operating system you observed the issue on.
Windows 10, Powershell

Environment Information: information about your project's environment, see instructions below:

  1. run the following script:

sh -c 'node --version; npm --version; npm ls' > output.txt

  1. share a gist with the contents of output.txt.
    gist of output.txt
@cdibbs
Copy link
Author

cdibbs commented Feb 17, 2018

I've added a project that demonstrates the bug.

https://github.com/cdibbs/tsnode-alsatian-scrambled-coverage-issue

It's also possible this is a ts-node bug, but I am not familiar enough with the inner workings of nyc or ts-node to know for sure.

@JaKXz
Copy link
Member

JaKXz commented Feb 4, 2019

@cdibbs sorry for the late reply. I'm not sure what you meant by:

there should be an option to cover all files, despite the absence of a require definition in the config.

I was going to suggest trying the newly published https://www.npmjs.com/package/@istanbuljs/nyc-config-typescript but I don't know how you'd get coverage without using a require hook.

@stale
Copy link

stale bot commented Apr 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 stale label Apr 5, 2019
@stale stale bot closed this as completed Apr 12, 2019
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