Skip to content

Latest commit

History

History
52 lines (39 loc) 路 1.61 KB

test.md

File metadata and controls

52 lines (39 loc) 路 1.61 KB

test

Gro integrates uvu for tests:

gro test # run all tests with Gro's default `*.test.ts` pattern
gro test thing.test somedir test/a.+b # run tests matching regexp patterns

Running gro test [...args] calls uvu's parse and run helpers inside Gro's normal task context instead of using the uvu CLI. Gro typically defers to a tool's CLI, so it can transparently forward args without wrapping, but in this case uvu doesn't support loaders for running TypeScript files directly. uvu does support require hooks, but Gro prefers the loader API.

Like other tasks, use --help to see the args info:

gro test --help

outputs:

gro test: run tests
[...args]  string[]           ["\\.test\\.ts$"]  file patterns to test
bail       boolean            false              the bail option to uvu run, exit immediately on failure
cwd        string             undefined          the cwd option to uvu parse
ignore     string | string[]  undefined          the ignore option to uvu parse

gro test runs all *.test.ts files in your project by default using the regexp "\\.test\\.ts$". So to add a new test, create a new file:

// by convention, create `src/lib/thing.ts`
// to test `src/lib/thing.test.ts`
import {test} from 'uvu';
import * as assert from 'uvu/assert';

import {thing} from '$lib/thing.js';

test('the thing', async () => {
	assert.equal(thing, {expected: true});
});

test.run();

See the uvu docs for more.