diff options
Diffstat (limited to 'std/testing/asserts.ts')
-rw-r--r-- | std/testing/asserts.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/std/testing/asserts.ts b/std/testing/asserts.ts index fe8b90f63..aa3017a4c 100644 --- a/std/testing/asserts.ts +++ b/std/testing/asserts.ts @@ -410,6 +410,23 @@ export function assertMatch( } /** + * Make an assertion that `actual` not match RegExp `expected`. If match + * then thrown + */ +export function assertNotMatch( + actual: string, + expected: RegExp, + msg?: string, +): void { + if (expected.test(actual)) { + if (!msg) { + msg = `actual: "${actual}" expected to not match: "${expected}"`; + } + throw new AssertionError(msg); + } +} + +/** * Forcefully throws a failed assertion */ export function fail(msg?: string): void { |