{"library":"node-test-helper","title":"Mocha Test Helper Suite","description":"node-test-helper is a legacy testing utility suite designed to simplify Mocha test setup by providing globally available assertions, mocking utilities, and test structure variables. Currently at version 1.0.0, the package's development appears to be abandoned, with no significant code updates in the past few years, despite a recent npm publish. Its approach relies heavily on CommonJS `require()` to inject global variables and functions (like `describe`, `it`, `expect`, `stub`, `TEST_NAME`) into the test environment, diverging significantly from modern modular JavaScript testing practices. It also presumes a `make`-based workflow for test execution rather than `npm scripts`, limiting its direct applicability in contemporary Node.js projects. Key differentiators (at the time of its creation) included simplifying boilerplate by abstracting away direct `require` calls for Mocha, Chai, and Sinon in individual test files, and offering an `init` command to scaffold a basic test directory structure and Makefile.","language":"javascript","status":"abandoned","last_verified":"Thu Apr 23","install":{"commands":["npm install node-test-helper"],"cli":{"name":"node-test-helper","version":null}},"imports":["require(\"node-test-helper\");","// Available globally after require(\"node-test-helper\");","// Available globally after require(\"node-test-helper\");"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const fs = require('fs');\nconst path = require('path');\n\n// Create a mock package.json to avoid 'make' install issues in a real quickstart\nfs.writeFileSync('package.json', JSON.stringify({ name: 'my-test-app', version: '1.0.0', devDependencies: { 'node-test-helper': '^1.0.0', 'mocha': '^10.0.0', 'chai': '^4.0.0', 'sinon': '^17.0.0', 'sinon-chai': '^3.0.0' } }), 'utf8');\n\n// Simulate npm install for quickstart context\nconsole.log('Simulating npm install...');\n// In a real environment, you'd run `npm install` here.\n// For a quickstart, we're assuming dependencies are met if we just show the test file.\n\n// Create a Makefile for 'make test'\nconst makefileContent = `\nTEST_RUNNER = ./node_modules/.bin/mocha\nTEST_OPTS = --recursive -t 30000 -R spec\n\ntest:\n\t@NODE_ENV=test $(TEST_RUNNER) $(TEST_OPTS) test/unit/\n\n.PHONY: test\n`;\nfs.writeFileSync('Makefile', makefileContent, 'utf8');\n\n// Create test directory structure\nfs.mkdirSync('test/unit', { recursive: true });\n\n// Create a sample test file\nconst testContent = `\n//-- test/unit/sample.test.js\nrequire(\"node-test-helper\");\n\ndescribe(TEST_NAME, function() {\n  describe(\"without callback\", function() {\n    it(\"should be successful\", function() {\n      expect(true).to.be.true;\n    });\n  });\n\n  describe(\"with callback\", function() {\n    it(\"should be successful asynchronously\", function(done) {\n      setTimeout(() => {\n        expect(false).to.be.false;\n        done();\n      }, 10);\n    });\n  });\n});\n`;\nfs.writeFileSync('test/unit/sample.test.js', testContent, 'utf8');\n\nconsole.log(\"To run the tests, first ensure mocha, chai, sinon, and sinon-chai are installed locally (e.g., 'npm install'). Then run: `make test`\");\nconsole.log(\"Expected output will show '2 passing'.\");\n","lang":"javascript","description":"This quickstart demonstrates how to set up and run a basic test file using `node-test-helper`'s global variable injection and a `make` command, including an asynchronous test example.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}