{"id":13670,"library":"node-test-github-reporter","title":"Node.js Test Runner GitHub Reporter","description":"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.","status":"active","version":"1.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/nearform/node-test-github-reporter","tags":["javascript","test","reporter","github"],"install":[{"cmd":"npm install node-test-github-reporter","lang":"bash","label":"npm"},{"cmd":"yarn add node-test-github-reporter","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-test-github-reporter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Parses Node.js test runner output to extract test results for reporting.","package":"node-test-parser","optional":false},{"reason":"Used for interacting with GitHub Actions environment variables and logging commands to set outputs and annotations.","package":"@actions/core","optional":false}],"imports":[{"note":"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.","wrong":"import { GitHubReporter } from 'node-test-github-reporter'","symbol":"Node.js CLI usage (primary)","correct":"node --test --test-reporter node-test-github-reporter"},{"note":"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.","symbol":"Combined Reporters","correct":"node --test --test-reporter spec --test-reporter-destination stdout --test-reporter node-test-github-reporter --test-reporter-destination stdout"}],"quickstart":{"code":"import { test } from 'node:test';\nimport { strict as assert } from 'node:assert';\n\n// Create a simple test file, e.g., 'test.js'\ntest('synchronous passing test', (t) => {\n  assert.strictEqual(1, 1, '1 should equal 1');\n});\n\ntest('asynchronous failing test', async (t) => {\n  await new Promise(resolve => setTimeout(resolve, 50));\n  assert.strictEqual(1, 2, '1 should not equal 2');\n});\n\n// Run the tests with the GitHub reporter\n// In your package.json, add a script:\n// \"test:github\": \"node --test --test-reporter node-test-github-reporter\"\n// Then run: npm run test:github\n// Or directly via CLI:\n// node --test --test-reporter node-test-github-reporter\n","lang":"javascript","description":"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."},"warnings":[{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.3.1':71 'action':123 'addit':103 'aim':125 'annot':31,61 'appear':73 'built':96 'built-in':95 'cadenc':80 'check':29 'ci':128 'command':41 'current':67 'depend':84 'design':14 'detail':59 'develop':111 'differenti':88 'direct':23 'driven':82 'experi':112 'failur':63 'feedback':129 'focus':108 'follow':75 'format':43 'framework':105 'frequent':77 'github':4,9,25,49,114,142 'immedi':120 'improv':110 'inlin':60 'integr':16,92 'javascript':139 'key':87 'loop':130 'make':117 'nativ':18,136 'node':7 'node-test-github-report':6 'node.js':1,19,39,98,132 'outcom':57 'output':36 'overview':54 'packag':65 'patch/minor':78 'primarili':81 'process':33 'project':133 'provid':51 'pull':27 'quick':53 'releas':79 'report':5,10,141 'request':28 'requir':101 'result':22,119 'runner':3,21,100,138 'seamless':91 'stabl':68 'streamlin':127 'test':2,8,20,35,40,56,99,104,118,137,140 'ui':50 'updat':85 'util':13,134 'version':70 'visibl':46,121 'within':47,113 'workflow':115","created_at":"2026-04-20T01:55:42.491531+00:00","updated_at":"2026-04-20T01:55:42.491531+00:00","problems":[{"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.","cause":"The GitHub reporter tried to post results but encountered an issue with GitHub API permissions or environment variables in the CI/CD pipeline.","error":"Error: Command failed: node --test --test-reporter node-test-github-reporter"},{"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.","cause":"The package was not installed or is not resolvable in the current environment.","error":"Error: The 'node-test-github-reporter' module could not be found."},{"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`.","cause":"Incorrect usage of the `--test-reporter-destination` flag, likely with a custom file path or invalid value.","error":"Node.js: --test-reporter-destination must be followed by 'stdout' or 'stderr'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/nearform/node-test-github-reporter","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/node-test-github-reporter","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}