summaryrefslogtreecommitdiff
path: root/Base/usr/share/man/man1/test-js.md
blob: 451743720fa8f16803ab55565d160f11e3d47e46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
## Name

test-js - run the LibJS test suite

## Synopsis

```**sh
$ test-js [options...] [path]
```

## Description

`test-js` runs the LibJS test suite located in `/home/anon/js-tests`. These
tests are using a custom JavaScript testing framework inspired by
[Jest](https://jestjs.io) (see [`test-common.js`](/home/anon/js-tests/test-common.js)).

It also supports the [test262 parser tests](https://github.com/tc39/test262-parser-tests).

The test root directory is assumed to be `/home/anon/js-tests`, or `$SERENITY_ROOT/Libraries/LibJS/Tests`
when using the Lagom build. Optionally you can pass a custom path to `test-js` to override these defaults.

You can disable output from `dbgln()` calls by setting the `DISABLE_DBG_OUTPUT` environment variable.

## Options

* `-t`, `--show-time`: Show duration of each test
* `-g`, `--collect-often`: Collect garbage after every allocation
* `--test262-parser-tests`: Run test262 parser tests

## Examples

A very simple test looks like this:

```js
describe("Examples from Gary Bernhardt's 'Wat' talk", () => {
    test("Na na na na na na na na na na na na na na na na Batman!", () => {
        expect(Array(16).join("wat" - 1) + " Batman!").toBe(
            "NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN Batman!"
        );
    });
});
```

## See also

* [`js`(1)](js.md)