Generating code coverage report in Jest

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • javascript-algorithms

    đź“ť Algorithms and data structures implemented in JavaScript with explanations and links to further readings

  • ‎As a demonstration code for this article, I’m going to use Oleksii Trekhleb’s javascript-algorithms repository. This repo is an awesome set of JavaScript implementations of the most famous algorithms (sorting, search, graphs, math algorithms, etc.) and data structures (heap, stack, queue, etc.), so besides learning how to generate a test coverage report in Jest, you’ll have a chance to learn some interesting JS tips and tricks.

  • nyc

    the Istanbul command line interface

  • uncovered part of the code For the coverage report Jest is using Istanbul (https://istanbul.js.org) under the hood, which is a general javascript coverage calculation tool.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • jest

    Delightful JavaScript Testing.

  • module.exports = { // The bail config option can be used here to have Jest stop running tests after // the first failure. bail: false, // Indicates whether each individual test should be reported during the run. verbose: false, // Indicates whether the coverage information should be collected while executing the test collectCoverage: false, // The directory where Jest should output its coverage files. coverageDirectory: './coverage/', // If the test path matches any of the patterns, it will be skipped. testPathIgnorePatterns: ['/node_modules/'], // If the file path matches any of the patterns, coverage information will be skipped. coveragePathIgnorePatterns: ['/node_modules/'], // The pattern Jest uses to detect test files. testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$', // This option sets the URL for the jsdom environment. // It is reflected in properties such as location.href. // @see: https://github.com/facebook/jest/issues/6769 testURL: 'http://localhost/', // @see: https://jestjs.io/docs/en/configuration#coveragethreshold-object coverageThreshold: { global: { statements: 100, branches: 95, functions: 100, lines: 100, }, }, };

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts