Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
A test runner with all the features you want, none of the complexity you don't, and no dependencies.
I think, therefore I test
Ergotest (pronounced air-go-test) is a Node.js library for writing and running tests. It emphasizes speed, functionality, and simplicity. It has a superb, well-documented automation API. It has all the features you need and none of the complexity you don't.
I built Ergotest because I wanted a tool I could automate easily. Compared to other testing tools, Ergotest is:
Despite its size, Ergotest is a modern test library with support for all the most important features:
describe()
for test suites, it()
for tests (easily renamed, if you wish)beforeAll()
, afterAll()
, beforeEach()
, afterEach()
.only
and .skip
to select tests; they work across files and nest cleanlyasync/await
for asynchronous codegetConfig()
makes custom configuration available within testsErgotest works particularly well with Automatopia. Together, they provide sophisticated build automation that automatically lints, compiles, and tests my TypeScript code in about 0.2 seconds.
Although Ergotest is battle-tested, it’s got some idiosyncracies. I'm still refining the API to make it more suitable for mainstream use. Until v1.0 is released, everything is subject to change, so you might want to wait.
import { assert, describe, it } from "ergotest";
import { hello } from "./hello.js";
export default describe(() => {
it("runs tests", async () => {
assert.equal(await hello.world(), "hello world");
});
describe("sub-suite", async () => {
it("placeholder test");
});
});
Ergotest is for Node.js only. It uses Node.js APIs and won’t work in the browser.
Other than that, Ergotest is designed for experienced practitioners using test-driven development. Several popular features are deliberately excluded, and are unlikely to ever be added:
Ergotest also doesn't include a command-line tool. You're expected to integrate it into your automated build. If you don’t have an automated build, try Automatopia, or use the starting point provided below.
npm install --save-dev ergotest
Isolate your tests from Ergotest by creating a tests.js
file. This allows you to easily customize or replace Ergotest in the future:
// tests.js
export * from "ergotest";
Write a simple test:
// example.test.js
import { assert, describe, it } from "./tests.js";
export default describe(() => {
it("runs tests", () => {
assert.equal(2 + 2, 4);
});
});
Use Ergotest's API to run tests from your automated build. For now, create a simple build.js
file:
import { TestRunner } from "ergotest/test_runner.js";
import path from "node:path";
const args = process.argv.slice(2);
const files = args.map(arg => path.resolve(process.cwd(), arg));
process.stdout.write("Running tests: ");
const result = await TestRunner.create().runInChildProcessAsync(files, { onTestCaseResult: reportProgress });
console.log("\n" + result.render("\n") + "\n");
function reportProgress(testCase) {
process.stdout.write(testCase.renderAsCharacter());
}
For more advanced builds, consider using Automatopia, which supports Ergotest out of the box. It includes features such as file globs, file watching, incremental testing, linting, and TypeScript compilation. (It’s also ridiculously fast, clocking at a fraction of a second in most cases.)
Run your tests:
node --enable-source-maps build.js *.test.js
(The --enable-source-maps
option causes Node to render TypeScript stack traces correctly.)
MIT License. See LICENSE.TXT.
FAQs
A test runner with all the features you want, none of the complexity you don't, and no dependencies.
The npm package ergotest receives a total of 24 weekly downloads. As such, ergotest popularity was classified as not popular.
We found that ergotest demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.