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

Using with code coverage [nyc + babel-plugin-istanbul] #37

Closed
4matic opened this issue Jan 26, 2018 · 3 comments
Closed

Using with code coverage [nyc + babel-plugin-istanbul] #37

4matic opened this issue Jan 26, 2018 · 3 comments

Comments

@4matic
Copy link

4matic commented Jan 26, 2018

How can I use this module to get coverage of my code? (nyc + babel-plugin-istanbul)
I figured out that under the hood you are using mocha-webpack.
I found 🔍 good issue for that
How about using with spinjs?

Also I have found lines where is possible change path for that:
https://github.com/sysgears/spinjs/blob/d76a58b4512ecf3bc6dda5b336eac135d47a1efa/src/executor.ts#L966-L975

@larixer
Copy link
Member

larixer commented Jan 26, 2018

@4matic Lets discuss in the chat:
https://gitter.im/sysgears/spinjs

To start, search babelConfig option in spinjs docs:
https://github.com/sysgears/spinjs#concepts

@4matic
Copy link
Author

4matic commented Feb 3, 2018

After a little discuss I found a way to apply this in my project:

First I used to try this for babelConfig option in .spinrc.js file as it is described here

{
  "options":{
    "babelConfig": {
      "presets": ["env"],
        "env": {
        "test": {
          "plugins": ["istanbul"]
        }
      }
    }
  }
}

But unfortunately this not worked...

So after that I tried other solution:
For this I used cross-env to set NODE_ENV to test:
nyc cross-env NODE_ENV=test spin test -t 15000 --full-trace --exit \"src/**/*.spec.js\"

And also added some condition to my .spinrc.js file:

if (process.env.NODE_ENV === 'test') {
  config.options.babelConfig = {
    "plugins": ["istanbul"]
  }
}

That's all.
Thanks to @Vlasenko for pointing out the correct direction of the idea.

@larixer
Copy link
Member

larixer commented Feb 3, 2018

@4matic Thank you very much for writing the solution here!

@larixer larixer closed this as completed Feb 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants