Fixes #3201. Assertions now throw a `TestFailure` error when they fail. This error is not exported or documented and should not be used or thrown manually. You cannot catch this error in order to recover from a failure, use `t.try()` instead. All assertions except for `throws` and `throwsAsync` now return `true` when they pass. This is useful for some of the assertions in TypeScript where they can be used as a type guard. Committing a failed `t.try()` result now also throws.
17 lines
530 B
TypeScript
17 lines
530 B
TypeScript
import {expectError} from 'tsd';
|
|
|
|
import test from '../../entrypoints/main.mjs';
|
|
|
|
test('snapshot', t => {
|
|
t.snapshot({foo: 'bar'});
|
|
t.snapshot(null, 'a snapshot with a message');
|
|
// @ts-expect-error TS2345
|
|
expectError(t.snapshot('hello world', null));
|
|
});
|
|
|
|
test('snapshot.skip', t => {
|
|
t.snapshot.skip({foo: 'bar'});
|
|
t.snapshot.skip(null, 'a snapshot with a message');
|
|
// @ts-expect-error TS2345
|
|
expectError(t.snapshot.skip('hello world', null)); // eslint-disable-line @typescript-eslint/no-confusing-void-expression
|
|
});
|