a_test
raw JSON → 1.0.9 verified Fri May 01 auth: no javascript
Compact test framework using when-style assertions with recursive test runner. Current stable version 1.0.9. Sub-package of the 'a' monorepo, focusing on minimalist TDD/BDD syntax. Differentiators: lightweight, recursive test discovery, when-style chaining for readable tests. Cadence: part of 'a' ecosystem, releases tied to main package.
Common errors
error Error: Cannot find module 'a_test' ↓
cause Package not installed or not in node_modules.
fix
Run 'npm install a_test' in your project.
error TypeError: (0 , a_test.describe) is not a function ↓
cause Using CommonJS require instead of ESM import.
fix
Change to 'import { describe } from 'a_test'' and ensure package.json has 'type': 'module'.
error ReferenceError: test is not defined ↓
cause Forgetting to call test.run() at the end of the test file.
fix
Add 'test.run();' after defining tests.
Warnings
breaking v1.0.0 switched from 'expect' to 'when' assertion syntax; existing tests using 'expect' will fail. ↓
fix Replace expect() calls with when().then() pattern.
deprecated describe.skip and it.skip are deprecated; use .skip property on the test callback instead. ↓
fix Use describe.skip(() => {}) or it.skip(() => {}).
gotcha Recursive test runner may cause infinite loops if tests are in parent directories without proper configuration. ↓
fix Set rootDir option in test.run({ rootDir: './tests' }) to limit scope.
Install
npm install a_test yarn add a_test pnpm add a_test Imports
- describe wrong
const describe = require('a_test')correctimport { describe } from 'a_test' - it wrong
import { test } from 'a_test'correctimport { it } from 'a_test' - when
import { when } from 'a_test'
Quickstart
import { describe, it, when } from 'a_test';
describe('Math', () => {
it('adds numbers', () => {
when(1 + 1).then(2);
});
});
test.run();