Skip to content

@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.

Terminal window
# npm
npm install -D @repobuddy/test
# yarn
yarn add -D @repobuddy/test
# pnpm
pnpm add -D @repobuddy/test
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()

With Vitest, use the @repobuddy/vitest/setup/order setup file from @repobuddy/vitest. It calls installOrder and adds the types.

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.
  • No CommonJS entry. require('@repobuddy/test') fails, so Jest must run test files as ESM to import it.
  • No automatic expect type augmentation. Only @repobuddy/vitest/setup/order augments types, and only for Vitest.
  • No setup file for Jest or other runners. Call installOrder from your own setup file.
  • isRunningInTest() does not detect test runs that execute in a regular, non-headless browser.