Skip to content

Latest commit

聽

History

History
47 lines (34 loc) 路 1.34 KB

test.md

File metadata and controls

47 lines (34 loc) 路 1.34 KB

test

Gro integrates Vitest for tests:

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

Running gro test [...args] calls Vitest inside Gro's normal task context. Vitest has native TypeScript support and excellent performance.

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

gro test --help

outputs:

gro test: run tests with vitest

[...args]          Array<string>      ['.test.']              file patterns to filter tests
dir                string             '/path/to/project/src/' working directory for tests
fail_without_tests boolean            false                   opt out of `passWithNoTests`
t                  string | undefined undefined               search pattern for test names, same as vitest -t and --testNamePattern

gro test runs all *.test.ts files in your project by default using the pattern ".test.". 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, expect} from 'vitest';

import {thing} from './thing.ts';

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

See the Vitest docs for more.