Skip to content

Commit

Permalink
docs: add docs for using rule tester with node:test
Browse files Browse the repository at this point in the history
  • Loading branch information
NotWoods committed May 6, 2024
1 parent f248e68 commit 97bee9b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/packages/Rule_Tester.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,28 @@ RuleTester.itOnly = vitest.it.only;
RuleTester.describe = vitest.describe;
```

#### Node built-in test runner

Consider setting up `RuleTester`'s static properties in a preloaded module using the [`--import`](https://nodejs.org/api/cli.html#--importmodule) or [`--require`](https://nodejs.org/api/cli.html#-r---require-module) flag:

```ts
// setup.js
import * as test from 'node:test';
import { RuleTester } from '@typescript-eslint/rule-tester';

RuleTester.afterAll = test.afterAll;

RuleTester.it = test.it;
RuleTester.itOnly = test.it.only;
RuleTester.describe = test.describe;
```

Tests can then be [run from the command line](https://nodejs.org/api/test.html#running-tests-from-the-command-line) like so:

```sh
node --import setup.js --test
```

## Options

### `RuleTester` constructor options
Expand Down

0 comments on commit 97bee9b

Please sign in to comment.