# API-Referenz zu node:test

Importieren Sie die Node-kompatible API zur Testregistrierung mit `node:test`:

```javascript
import test, { describe, it } from "node:test";

test("addition", (t) => {
  t.assert.strictEqual(1 + 1, 2);
});

describe("math", () => {
  it("multiplies", (t) => {
    t.assert.strictEqual(2 * 3, 6);
  });
});
```

## Verfügbare Oberfläche

| Bereich | Mitglieder |
|---|---|
| Tests und Suites | `test` / `it`, `describe` / `suite`, dazu `.skip`, `.todo` und `.only` |
| Hooks | `before`, `after`, `beforeEach`, `afterEach` |
| Testkontext | `t.assert`, `t.test`, Hooks, `t.diagnostic`, `t.plan`, `t.skip`, `t.todo`, `t.mock`, `t.signal` |
| Mocks | `mock.fn`, `mock.method`, Mocks für Eigenschaften und Accessoren, Fake-Timer, Zurücksetzen und Wiederherstellen |
| Modul-Assertions | `test.assert` |

Snapshot-Assertions, `mock.module()` und der programmatische Einstiegspunkt `run()`
sind nicht implementiert.

## Tests ausführen

Führen Sie `node:test`-Dateien mit `elide test` aus, das auch eine explizite Datei
akzeptiert:

```bash
elide test ./math.test.mjs
```

`elide run` registriert die Tests, ohne sie auszuführen, und gibt stattdessen den zu
verwendenden `elide test`-Befehl aus.

## Siehe auch

- [Node.js-Test-API](https://nodejs.org/api/test.html)

<!-- api-reference:start c3c2a6313f8a -->
## Reference

**Status:** Partial · Not measured · since 1.1.0

### Exports

| Export | Kind | Status | Notes |
| --- | --- | --- | --- |
| `test()` | function | Full | Define and run a test case |
| `it()` | function | Full | Alias for test() |
| `describe()` | function | Full | Group tests into a suite |
| `suite()` | function | Full | Alias for describe() |
| `before()` | function | Full | Register a function to run before all tests in the current suite |
| `after()` | function | Full | Register a function to run after all tests in the current suite |
| `beforeEach()` | function | Full | Register a function to run before each test in the current suite |
| `afterEach()` | function | Full | Register a function to run after each test in the current suite |
| `mock` | property | Full | The mock object for creating spies and mocking timers |

### Not implemented

`expectFailure`, `getTestContext`.
<!-- api-reference:end -->
