All Projects → jaydenseric → coverage-node

jaydenseric / coverage-node

Licence: MIT license
A simple CLI to run Node.js and report code coverage.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to coverage-node

find-unused-exports
A Node.js CLI and equivalent JS API to find unused ECMAScript module exports in a project.
Stars: ✭ 30 (-23.08%)
Mutual labels:  esm, maintained, npx, mjs
extract-files
A function to recursively extract files and their object paths within a value, replacing them with null in a deep clone without mutating the original value. FileList instances are treated as File instance arrays. Files are typically File and Blob instances.
Stars: ✭ 48 (+23.08%)
Mutual labels:  esm, maintained, mjs
atjson
atjson is a living content format for annotating content
Stars: ✭ 192 (+392.31%)
Mutual labels:  maintained
loaders
ECMAScript Modules Loaders
Stars: ✭ 65 (+66.67%)
Mutual labels:  esm
OldCEF4Delphi
OldCEF4Delphi is an open source project to embed Chromium-based browsers in applications made with Delphi.
Stars: ✭ 55 (+41.03%)
Mutual labels:  v8
frontend-gradle-plugin
All-in-one Gradle Node plugin, Gradle NPM plugin, Gradle Yarn Berry plugin to build Javascript applications with Gradle: distribution management, built-in tasks.
Stars: ✭ 120 (+207.69%)
Mutual labels:  npx
extension-generator
This package is no longer supported. Please use https://github.com/flarum/cli instead.
Stars: ✭ 53 (+35.9%)
Mutual labels:  npx
zig-v8
Simple V8 builds with C and Zig bindings.
Stars: ✭ 87 (+123.08%)
Mutual labels:  v8
react-native-js-benchmark
JavaScript Engine Benchmark for React Native
Stars: ✭ 100 (+156.41%)
Mutual labels:  v8
node-mini
Mini Node.js runtime built on V8
Stars: ✭ 24 (-38.46%)
Mutual labels:  v8
v8-android-buildscripts
V8 build scripts for React Native Android
Stars: ✭ 63 (+61.54%)
Mutual labels:  v8
docker-v8
Docker V8 Image
Stars: ✭ 26 (-33.33%)
Mutual labels:  v8
all-about-node
All about Node.js
Stars: ✭ 16 (-58.97%)
Mutual labels:  v8
tailwind-layouts
Collection of Tailwind Layouts
Stars: ✭ 53 (+35.9%)
Mutual labels:  esm
FENews.org
fenews.org
Stars: ✭ 20 (-48.72%)
Mutual labels:  v8
nsplayer
A web player with shakaplayer & hls.js both supported
Stars: ✭ 23 (-41.03%)
Mutual labels:  esm
npmy
`npm/npx/npm link` on steroids.
Stars: ✭ 58 (+48.72%)
Mutual labels:  npx
create-layout
🦚 Make layout.md for a better view of your project structure.
Stars: ✭ 12 (-69.23%)
Mutual labels:  npx
resolve-typescript-plugin
webpack plugin to resolve TypeScript files when importing with js file extension in ESM projects
Stars: ✭ 39 (+0%)
Mutual labels:  esm
openrasp-v8
Google V8 with OpenRASP builtins
Stars: ✭ 42 (+7.69%)
Mutual labels:  v8

coverage-node

A simple CLI to run Node.js and report code coverage.

Installation

To install coverage-node with npm, run:

npm install coverage-node --save-dev

In a package.json script, replace the node command with coverage-node:

 {
   "scripts": {
-    "test": "node test.mjs"
+    "test": "coverage-node test.mjs"
   }
 }

Requirements

Supported operating systems:

  • Linux
  • macOS

Supported runtime environments:

  • Node.js versions ^14.17.0 || ^16.0.0 || >= 18.0.0.

Projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check comment:

Ignored files

Code coverage analysis ignores:

  • node_modules directory files, e.g. node_modules/foo/index.mjs.
  • test directory files, e.g. test/index.mjs.
  • Files with .test prefixed before the extension, e.g. foo.test.mjs.
  • Files named test (regardless of extension), e.g. test.mjs.

Ignored lines

In source code, a comment (case insensitive) can be used to ignore code coverage ranges that start on the the next line:

// coverage ignore next line
if (false) console.log("Never runs.");

CLI

Command coverage-node

Substitutes the normal node command; any node CLI options can be used to run a test script. If the script doesn’t error a code coverage analysis is reported to the console, and if coverage is incomplete and there isn’t a truthy ALLOW_MISSING_COVERAGE environment variable the process exits with code 1.

Examples

npx can be used to quickly check code coverage for a script:

npx coverage-node test.mjs

A package.json script:

{
  "scripts": {
    "test": "coverage-node test.mjs"
  }
}

A package.json script that allows missing coverage:

{
  "scripts": {
    "test": "ALLOW_MISSING_COVERAGE=1 coverage-node test.mjs"
  }
}

Exports

The npm package coverage-node features optimal JavaScript module design. It doesn’t have a main index module, so use deep imports from the ECMAScript modules that are exported via the package.json field exports:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].