I'm designing my tests using the Behavior Driven Development (BDD) approach using Gherkin syntax and running my tests with Cucumber JS.
I'm using Cucumber Studio to share reports and keep synced with my business stakeholders, and management.
Recently I needed to get test coverage reports for the project, and made some research but couldn't decide which library to use to get coverage reports and how.
So far I've found JSCover, Cucumber Reports, and Istanbul for test coverage reports, but I'm not sure how to use them exactly and which would be best for my case to use with Cucumber JS.
I'm designing my tests using the Behavior Driven Development (BDD) approach using Gherkin syntax and running my tests with Cucumber JS.
I'm using Cucumber Studio to share reports and keep synced with my business stakeholders, and management.
Recently I needed to get test coverage reports for the project, and made some research but couldn't decide which library to use to get coverage reports and how.
So far I've found JSCover, Cucumber Reports, and Istanbul for test coverage reports, but I'm not sure how to use them exactly and which would be best for my case to use with Cucumber JS.
Share Improve this question asked Apr 11, 2021 at 9:46 ChoottiChootti 4866 silver badges16 bronze badges 2- Are you tests run in a browser? (like karma or selenium) or is everything run inside node.js? – Alex028502 Commented May 5, 2021 at 19:43
-
Actually currently they run on node executions, not on the browser directly. They include
unit
,ponent
,integration
, ande2e
tests which don't require a browser to run. The most external test is E2E and it uses gRPC requests. – Chootti Commented May 11, 2021 at 17:49
1 Answer
Reset to default 7After several trials, I've figured out that it is pretty simple to use Istanbul JS to see code coverage.
I've followed the instructions on the website and install Istanbul's JavaScript library nyc
using:
yarn add -D nyc
Then, I've updated my scripts
in the package.json
as the following:
...
"scripts": {
"test": "cucumber-js ...",
...
"coverage": "nyc yarn test"
},
...
And when I run yarn coverage
it runs the tests with wrapping by nyc
and creating a coverage report as the following: