{"library":"node-qunit","title":"QUnit Test Runner for Node.js","description":"node-qunit is a specialized test runner designed to integrate the QUnit testing framework with Node.js environments. Currently at version 2.0.2, this package was last published seven years ago and is now considered abandoned. It differentiates itself by running each test file in its own spawned Node.js process, enabling parallel execution for improved performance. It offers both a command-line interface (CLI) and a programmatic API for integrating with build systems. While providing test coverage via Istanbul, its core value proposition was maintaining API compatibility with the browser-based QUnit, allowing for consistent test writing across client and server environments. It aimed for a simplified API, particularly for asynchronous testing, and supported both TDD and BDD styles. Given its abandonment, users should exercise caution or consider more modern alternatives.","language":"javascript","status":"abandoned","last_verified":"Tue Apr 21","install":{"commands":["npm install node-qunit"],"cli":{"name":"qunit","version":null}},"imports":["const testrunner = require(\"node-qunit\");","QUnit.module('My tests', function() { /* ... */ });","QUnit.test('My test case', function(assert) { /* ... */ });"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const testrunner = require(\"node-qunit\");\nconst path = require(\"path\");\nconst fs = require(\"fs\");\n\n// Define a simple code file to be tested\nconst codeFilePath = path.join(__dirname, \"my-code.js\");\nfs.writeFileSync(codeFilePath, `\nmodule.exports = {\n  add: (a, b) => a + b,\n  subtract: (a, b) => a - b\n};\n`);\n\n// Define a simple test file using QUnit API\nconst testFilePath = path.join(__dirname, \"my-tests.js\");\nfs.writeFileSync(testFilePath, `\nQUnit.module('Calculator', function(hooks) {\n  hooks.beforeEach(function(assert) {\n    // Setup code if needed\n  });\n\n  QUnit.test('add function', function(assert) {\n    const calculator = require('./my-code.js'); // Relative path needed for child process\n    assert.equal(calculator.add(1, 2), 3, '1 + 2 should be 3');\n  });\n\n  QUnit.test('subtract function', function(assert) {\n    const calculator = require('./my-code.js');\n    assert.equal(calculator.subtract(5, 2), 3, '5 - 2 should be 3');\n  });\n});\n`);\n\n// Configure and run the tests\ntestrunner.run({\n    code: codeFilePath,\n    tests: testFilePath,\n    log: {\n        summary: true,\n        errors: true,\n        coverage: false // Assuming no istanbul setup for quickstart\n    }\n}, function(err, report) {\n    if (err) {\n        console.error(\"Test runner encountered an error:\", err);\n        process.exit(1);\n    }\n    console.log(\"Test Report:\", JSON.stringify(report, null, 2));\n    // Cleanup generated files\n    fs.unlinkSync(codeFilePath);\n    fs.unlinkSync(testFilePath);\n    process.exit(report.globalSummary.failed > 0 ? 1 : 0);\n});","lang":"javascript","description":"Demonstrates how to programmatically run QUnit tests in Node.js, including setting up a simple code file and its corresponding test file using the `node-qunit` test runner API. This example creates temporary files to illustrate the `code` and `tests` configuration.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}