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 breaks the test translated by ts-node #1270

Closed
1 task done
shanoaice opened this issue Jan 21, 2020 · 7 comments
Closed
1 task done

nyc breaks the test translated by ts-node #1270

shanoaice opened this issue Jan 21, 2020 · 7 comments
Labels

Comments

@shanoaice
Copy link

Link to bug demonstration repository

I used it in one of my project, the link is here
I wrote my test file in TypeScript and I transform them at runtime with ts-node/register. When I run ava without nyc everything works fine, but when I run ava with nyc, ts-node gave a lot of error.

Expected Behavior

Run the tests as normal with not error.

Observed Behavior

ts-node gave a lot of strange error. I suppose that it is related to how nyc processes the test file

Troubleshooting steps

  • still occurring when I put cache: false in my nyc config

Environment Information

System:
    OS: Linux 4.4 Ubuntu 19.10 (Eoan Ermine)
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    Memory: 1022.06 MB / 7.83 GB
  Binaries:
    Node: 12.14.1 - ~/.nvs/default/bin/node
    Yarn: 1.21.1 - ~/.nvs/default/bin/yarn
    npm: 6.13.4 - ~/.nvs/default/bin/npm
  npmPackages:
    @ava/babel: 1.0.0 => 1.0.0
    nyc: ^15.0.0 => 15.0.0
    ts-node: 8.6.2 => 8.6.2
    typescript: 3.8.0-dev.20200119 => 3.8.0-dev.20200119
@coreyfarrell
Copy link
Member

Can you post an example of the ts-node errors or better yet a link to the log of a failed CI run?

This is a difficult situation as it appears you have 4 transpilers running in your tests - ava is enabling babel, esm and ts-node, then nyc is enabling another copy of babel. Might be that you need to tell nyc to not instrument and instead configure ava to enable babel-plugin-istanbul. I haven't been following recent developments with ava but I know some changes have been made to how it integrates with babel.

@shanoaice
Copy link
Author

Can you post an example of the ts-node errors or better yet a link to the log of a failed CI run?

This is a difficult situation as it appears you have 4 transpilers running in your tests - ava is enabling babel, esm and ts-node, then nyc is enabling another copy of babel. Might be that you need to tell nyc to not instrument and instead configure ava to enable babel-plugin-istanbul. I haven't been following recent developments with ava but I know some changes have been made to how it integrates with babel.

I didn't have a CI build link, but I will post an error report soon. I will try your solution too, but I've also tried c8 and it is working well.

@shanoaice
Copy link
Author

Here's the gist, generated using my repo KsRyY/bethlehem@8a9ff76

@shanoaice
Copy link
Author

Still does not work well when using the babel provider of ava (@ava/babel)

@andywampir
Copy link

andywampir commented Mar 28, 2020

I tried to downgrade nyc to 14.1.1 and it's partially helps me, now tests runs normally but code coverage always 0
image

@andywampir
Copy link

In my case (i'm writing API wrapper) i just increased ava testing timeout and [email protected] works normally.

@KsRyY Try increase timeout, maybe it helps you too

@stale
Copy link

stale bot commented Jun 18, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

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

@stale stale bot added the stale label Jun 18, 2021
@stale stale bot closed this as completed Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants