Registry / devops / node-test-github-reporter

node-test-github-reporter

JSON →
library1.3.1jsnpmunverified

node-test-github-reporter is a utility designed to integrate the native Node.js test runner results directly into GitHub's Pull Request checks and annotations. It processes the test output from the Node.js `--test` command and formats it for visibility within the GitHub UI, providing a quick overview of test outcomes and detailed inline annotations for failures. The package is currently stable at version 1.3.1 and appears to follow a frequent patch/minor release cadence, primarily driven by dependency updates. Its key differentiator is its seamless integration with the built-in Node.js test runner, requiring no additional testing frameworks, and its focus on improving developer experience within GitHub workflows by making test results immediately visible and actionable. It aims to streamline CI feedback loops for Node.js projects utilizing the native test runner.

npm install node-test-github-reporter
INSTALL
IMPORT
SIG · NODE-TEST-GITHUB-R
N
node-test-github-reporter
devopsjavascriptv1.3.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Node.js CLI usage (primary)
node --test --test-reporter node-test-github-reporter
import { GitHubReporter } from 'node-test-github-reporter'
This package is designed to be used as a `--test-reporter` CLI flag with the Node.js test runner, not as a direct programmatic import. Attempting to import it programmatically will not expose its reporter functionality directly.
Combined Reporters
node --test --test-reporter spec --test-reporter-destination stdout --test-reporter node-test-github-reporter --test-reporter-destination stdout
To view test output in the console while also reporting to GitHub, chain reporters. Ensure each reporter specifies its `--test-reporter-destination` if you want separate outputs.

Demonstrates setting up a basic Node.js test file and executing it with the `node-test-github-reporter` to integrate results with GitHub Actions checks.

import { test } from 'node:test'; import { strict as assert } from 'node:assert'; // Create a simple test file, e.g., 'test.js' test('synchronous passing test', (t) => { assert.strictEqual(1, 1, '1 should equal 1'); }); test('asynchronous failing test', async (t) => { await new Promise(resolve => setTimeout(resolve, 50)); assert.strictEqual(1, 2, '1 should not equal 2'); }); // Run the tests with the GitHub reporter // In your package.json, add a script: // "test:github": "node --test --test-reporter node-test-github-reporter" // Then run: npm run test:github // Or directly via CLI: // node --test --test-reporter node-test-github-reporter
Debug
Known issues
gotchaThe reporter relies on specific GitHub Actions environment variables (e.g., GITHUB_TOKEN, GITHUB_SHA, GITHUB_REPOSITORY). If these are not correctly set, the reporter may not be able to post results to GitHub checks or annotations, leading to silent failures in reporting.
fix
Ensure the GitHub Actions workflow grants appropriate permissions (e.g., `permissions: write-all` or specific `checks: write`, `pull-requests: write`) and passes the `GITHUB_TOKEN` to the job. Verify environment variables like `GITHUB_SHA` and `GITHUB_REPOSITORY` are available in the action's context.
affects: >=1.0.0
gotchaWhen combining with other reporters, it's crucial to explicitly define output destinations using `--test-reporter-destination`. If not specified, multiple reporters might attempt to write to stdout simultaneously, leading to garbled or incomplete output for one or both.
fix
For combined usage, always specify `--test-reporter-destination stdout` for reporters whose output you want in the console, and rely on the GitHub reporter to handle its own internal reporting mechanism without needing an explicit destination for GitHub interaction.
affects: >=1.0.0
gotchaThis reporter is specifically designed for the native Node.js test runner (introduced in Node.js v18.x). It will not work with other testing frameworks like Jest, Mocha, or Vitest, even if they use a similar CLI interface for running tests.
fix
Ensure your project is exclusively using the `node:test` module for its testing infrastructure. For other frameworks, seek out their specific GitHub integration reporters.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Command failed: node --test --test-reporter node-test-github-reporter
The GitHub reporter tried to post results but encountered an issue with GitHub API permissions or environment variables in the CI/CD pipeline.
fix
Verify that your GitHub Actions workflow has sufficient permissions (`pull-requests: write` or `checks: write`) and that the `GITHUB_TOKEN` is correctly passed to the job executing the tests. Ensure other required GitHub environment variables are present.
Error: The 'node-test-github-reporter' module could not be found.
The package was not installed or is not resolvable in the current environment.
fix
Run `npm install --save-dev node-test-github-reporter` or `yarn add --dev node-test-github-reporter` to ensure the package is installed as a development dependency.
Node.js: --test-reporter-destination must be followed by 'stdout' or 'stderr'
Incorrect usage of the `--test-reporter-destination` flag, likely with a custom file path or invalid value.
fix
The Node.js native test runner only supports `stdout` or `stderr` as destinations for built-in or custom reporters. Correct the flag to `--test-reporter-destination stdout` or `--test-reporter-destination stderr`.
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies
node-test-parserrequiredParses Node.js test runner output to extract test results for reporting.
@actions/corerequiredUsed for interacting with GitHub Actions environment variables and logging commands to set outputs and annotations.
Agent activity
2 hits · last 30 days
node
2
Resources
node-test-github-reporter — npm install node-test-github-reporter · libregistry