@repobuddy/test
@repobuddy/test holds test utilities that do not depend on one test runner. Most projects get it through
@repobuddy/vitest, which re-exports it. Install it directly to use it with Jest or another
runner.
Install
Section titled “Install”# npmnpm install -D @repobuddy/test
# yarnyarn add -D @repobuddy/test
# pnpmpnpm add -D @repobuddy/testChoose an export
Section titled “Choose an export”| You want to | Use |
|---|---|
| Assert that callbacks run in a planned order | installOrder(expect), then expect.order.plan(n) |
Create an order assertion without touching expect |
order.plan(n) |
Type expect.order for your runner |
ExpectWithOrder |
| Catch an order failure by class | InvalidOrder |
| Tell a test run from a real browser session | isRunningInTest() |
Guides
Section titled “Guides”With Vitest, use the @repobuddy/vitest/setup/order setup file from @repobuddy/vitest. It
calls installOrder and adds the types.
Support
Section titled “Support”| Area | Support |
|---|---|
| Test runners | Any runner whose expect is an object. installOrder only defines a property on it. Covered by tests: Vitest. Checked by hand: Jest 30 in ESM mode. |
| Peer dependencies | None. The one dependency is assertron (^11.7.0). |
| Node.js | No engines field. |
| Module format | ESM only. The . export has an import condition and no require condition. |
Environments for isRunningInTest() |
Covered by tests: Node.js and Vitest browser mode (Chromium). The code also checks for an Edge runtime global and for jsdom, HappyDOM, StorybookTestRunner, or HeadlessChrome in the user agent. See the rules. |
| TypeScript | Ships .d.ts files. The exports map also has a source condition that points at src/index.ts. |
Not supported
Section titled “Not supported”- No CommonJS entry.
require('@repobuddy/test')fails, so Jest must run test files as ESM to import it. - No automatic
expecttype augmentation. Only@repobuddy/vitest/setup/orderaugments types, and only for Vitest. - No setup file for Jest or other runners. Call
installOrderfrom your own setup file. isRunningInTest()does not detect test runs that execute in a regular, non-headless browser.