# fwa

A test runner for TypeScript code. The module finds tests, checks them against their source files, and passes the exact list of tests directly to Node.js.

## Installation

Use Node.js `20.19.0` or later.

```sh
npm install --save-dev fwa
```

## First test

Save the test in the `src` directory.

`src/example.test.ts`

```ts
import { strict as assert } from 'node:assert';
import { test } from 'node:test';

test('adds two numbers', () => {
  assert.equal(2 + 3, 5);
});
```

Configure TypeScript to compile the sources from `src` into `dist`.

`tsconfig.json`

```json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "rootDir": "src",
    "outDir": "dist",
    "strict": true,
    "types": [
      "node"
    ]
  },
  "include": [
    "src/**/*.ts"
  ]
}
```

Add the module type and the build and test scripts to `package.json`.

`package.json`

```json
{
  "type": "module",
  "scripts": {
    "build": "tsc",
    "test": "fwa --prune"
  }
}
```

Build the project and run the tests. `fwa` will match `dist/example.test.js` to its source test and pass it to `node:test`.

```sh
npm run build
npm test
```

---

Article on Habr (in Russian) — [Between tsc and node:test: how to catch stale tests in dist](https://habr.com/ru/articles/1066056/).
