test-runner is a fully-featured, lightweight command-line test runner designed for full-stack JavaScript engineers to create and test modern, isomorphic code. It operates by taking one or more files, each exporting a `test object model` (TOM) instance, running the contained tests with controlled order and concurrency, and generating a report. Currently at version `0.11.1`, the project is explicitly marked as "Work In Progress," indicating an active development phase with potential for frequent, non-semver compliant breaking changes before a stable `1.0` release. Its key differentiators include native support for both CommonJS and ECMAScript modules, execution in Node.js and headless Chromium for isomorphic testing, and a unique `Tom` API for defining test suites, distinguishing it from runners relying on global functions or specific assertion libraries. It aims to be part of a broader suite of JavaScript testing tools.
npm install test-runnerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up and run basic synchronous and asynchronous tests using `test-runner` in a Node.js CommonJS environment, including an external dependency (`node-fetch`) for API testing.
Monitor the project's GitHub repository and release notes closely for updates. Consider pinning to exact versions for critical projects and thorough testing after updates.
Ensure your Node.js environment meets the minimum requirement by upgrading to version 12.17 or newer (e.g., using nvm or your package manager).
Refer to the 'test-object-model' documentation and the 'test-runner' README for examples on how to correctly structure test files using the `Tom` instance.
Ensure consistency in your module system. For ESM, use `import` statements and ensure your `package.json` has `"type": "module"`. For CJS, use `require` statements. Refer to Node.js documentation on module systems.
Use universal APIs or conditional logic (e.g., checking `typeof window`) within your tests, or create distinct test files and run configurations for browser-only and Node.js-only code.
Switch to `import { Tom } from 'test-runner'` or change your file to be a CommonJS module by removing `"type": "module"` from `package.json` or changing the file extension to `.cjs`.If in a CommonJS context, use `const { Tom } = require('test-runner')`. If in ESM, ensure your `package.json` correctly defines module type and exports, and that the `test-runner` package correctly provides ESM exports.Ensure you have `const { Tom } = require('test-runner')` (or `import { Tom } from 'test-runner')` and `const tom = new Tom()` in your test file, and that the test file exports the `tom` instance: `module.exports = tom`.Verify the file paths and patterns provided to `test-runner`. Use glob patterns cautiously and ensure they match your file structure. E.g., `npx test-runner 'test/**/*.js'`.