Can someone recommend the most effective method to obtain coverage statistics in cucumber js?

With my testing approach based on Behavior Driven Development (BDD), I utilize Gherkin syntax for test design and run tests using Cucumber JS.

To collaborate with business stakeholders and management, I leverage Cucumber Studio to share reports and stay in sync.

Recently, I needed test coverage reports for the project and conducted research to find the best library. However, I'm unsure about which one to use and how to implement it effectively with Cucumber JS.

Among the options I've come across are JSCover, Cucumber Reports, and Istanbul for test coverage reports, but I need guidance on their specific usage and the most suitable choice for integrating with Cucumber JS.

Answer №1

After experimenting with different approaches, I have discovered a straightforward way to utilize Istanbul JS for code coverage analysis.

By following the instructions provided on the official website, I proceeded to install Istanbul's JavaScript library known as nyc using the command:

yarn add -D nyc

Subsequently, I made necessary adjustments to the scripts section within my package.json file, which now looks like this:

...
  "scripts": {
    "test": "cucumber-js ...",
    ...
    "coverage": "nyc yarn test"
  },
...

Upon executing the command yarn coverage, the tests are run in conjunction with nyc, generating a comprehensive coverage report that can be viewed here:

https://i.sstatic.net/Ym24W.jpg

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Accessing object properties using a string for the variable name in Javascript

As I develop a Music composition program in JavaScript, I have encountered a challenge when it comes to iterating through my data quickly. My JSON object, named song, is structured like this: song = {"track0":"data...", "track1":"data...", ...}; I am con ...

ng-model establishes a connection with objects, not properties

Having just started my journey with AngularJS and JavaScript, I decided to create a simple app that allows users to input their name and age, and then displays the list of users and their ages. Here is the code I put together: var main = angular.module( ...

Using jQuery in an external JavaScript file may encounter issues

As a newcomer to jQuery, I decided to try writing my jQuery code in an external js file rather than embedding it directly into the head of the HTML file. Unfortunately, this approach did not work as expected. Here is what my index.html looks like: < ...

Shuffle order of AngularJS ng-repeat array

I am struggling to create a basic grammar quiz where I need to randomly sort an array using ng-repeat. The goal is to display both correct and incorrect sentences in random order. Below you can find my code snippet: (function(angular) { 'use str ...

Updating an element in an array at a specific index in MongoDB and adding a new document if no match is found

UPDATE: My main goal with this query is to find a quick solution, as I am new to MongoDB and assumed using a single query would be the fastest option. However, any fast solution will suffice. Essentially, I am seeking a solution for the following issue. W ...

Efficiently sift through a vast assortment using a filtering method

Currently, I am developing an application similar to Uber which involves managing a collection of drivers with their current positions (latitude and longitude). One specific requirement is to find drivers who are within a 200-meter distance from the user& ...

How do I include an icon on the far left of my NavBar menu? I'm having trouble figuring out how to add an icon to the header NavBar

How can I add an icon to the left of my NavBar header? I am struggling with adding an icon on the far left side of my NavBar. The NavBar is a custom class from NavBar.js. I want to include an icon in this bar on the leftmost side. I have already added b ...

Highlighting the current menu item by comparing the URL and ID

Looking to make my navigation menu items active based on URL and ID, rather than href. None of the suggested solutions (like this one, this one, or this one) have worked for me. This is how my Navigation is designed: <nav id="PageNavigation"& ...

Positioning the infowindow in Google Maps API v3

Creating a map with various markers, each with its own info window. However, when attempting to display an info window on multiple markers, the position remains fixed at the first clicked marker. What could be causing this issue? <script type="text/jav ...

Scraping data without a browser: Selenium, phantomJS, and Geb

I have a task of extracting data from a website on a weekly basis. The data is only visible after clicking on the page (triggering a Javascript function). It is loaded into a table which can be identified by its unique ID. This script needs to be executed ...

Serve static files outside the root directory with Grunt Connect

I'm facing issues configuring my grunt file to include references (css & js) in my index.html Below is my project structure: src/ demo/ index.html app.js bower_components/ angular/ angular.js index.html: <script src="./bower_compo ...

Looking for a way to automatically update your JavaScript code on your Minecraft (Bukkit)

One of my clients has requested a website design that includes a player display for each server, updating every five seconds. I'm not sure where to start with this task. Below is an example for reference. Any guidance on how to achieve this would be g ...

The data submitted from the form did not successfully get inserted into the database row

Currently, I am working on integrating a new product into my products database using ajax with php and mysql PDO. The form is located in a separate HTML file and gets loaded into a Bootstrap modal when the "add product" button is clicked. Below you can fi ...

How to Ensure a Component is Loaded Only Once in React JS

Currently, I am working on a React App with two pages - Home and My Portfolio Section. The Portfolio Section consists of two functional components. Home.js import React from 'react' const Home = () => { return ( <h1>Home Screen&l ...

Validating dates in TypeScript

Currently, I am studying date handling and have an object that contains both a start and end date. For example: Startdate = "2019-12-05" and Enddate = "2020-05-20" My goal is to establish a condition that first verifies the dates are not empty. After tha ...

Emit data asynchronously upon returning

In my node.js application, I have a background process implemented using the EventEmitter. Here is a snippet of how it is used: var event = { returnValue: undefined }; eventEmitter.emit('name', event, argument); return event.returnValue; // This ...

Prevent the dropdown from closing after clicking on a href link

Is there a way to ensure that my dropdown remains open even after a page reload? I'm looking for a solution where clicking on an item(href) within the dropdown will keep it open after redirection. I've tried using the jQuery method called stopPr ...

What is the best way to recover past messages from a channel?

I am working on a bot that is supposed to be able to retrieve all messages from a specific server and channel upon request. I attempted to use the channel.messages.cache.array() method, but it only returned an empty array []. How can I efficiently fetch ...

To incorporate an if-else statement into an onClick event depending on the selected radio button option

My page currently loads two separate lists of data as cards from different URLs: http://localhost:3000/videos http://localhost:3000/manuals I have a div that displays both lists together and a "Create Card" button that opens a modal. After filling in the ...

Having trouble with a Reactjs Facebook login library - update the componentClicked function to be async

Currently, I am working on incorporating Facebook login into my React application using Redux. Within my loginUser.js file, the "FacebookLogIn" component appears as follows: <FacebookLogin appId="375026166397978" autoLoad={true} fields="name, ...