mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
docs(std/testing) add a description of assertNotMatch(). (#7470)
This commit is contained in:
parent
cf91550c65
commit
5819cfbeec
1 changed files with 11 additions and 2 deletions
|
@ -12,7 +12,7 @@ Deno.test("Hello Test", () => {
|
|||
});
|
||||
```
|
||||
|
||||
The assertions module provides nine assertions:
|
||||
The assertions module provides 10 assertions:
|
||||
|
||||
- `assert(expr: unknown, msg = ""): asserts expr`
|
||||
- `assertEquals(actual: unknown, expected: unknown, msg?: string): void`
|
||||
|
@ -21,6 +21,7 @@ The assertions module provides nine assertions:
|
|||
- `assertStringContains(actual: string, expected: string, msg?: string): void`
|
||||
- `assertArrayContains(actual: unknown[], expected: unknown[], msg?: string): void`
|
||||
- `assertMatch(actual: string, expected: RegExp, msg?: string): void`
|
||||
- `assertNotMatch(actual: string, expected: RegExp, msg?: string): void`
|
||||
- `assertThrows(fn: () => void, ErrorClass?: Constructor, msgIncludes = "", msg?: string): Error`
|
||||
- `assertThrowsAsync(fn: () => Promise<void>, ErrorClass?: Constructor, msgIncludes = "", msg?: string): Promise<Error>`
|
||||
|
||||
|
@ -115,7 +116,8 @@ Deno.test("Test Assert Array Contains", () => {
|
|||
|
||||
### Regex
|
||||
|
||||
You can assert regular expressions via the `assertMatch()` assertion.
|
||||
You can assert regular expressions via `assertMatch()` and `assertNotMatch()`
|
||||
assertions.
|
||||
|
||||
```js
|
||||
Deno.test("Test Assert Match", () => {
|
||||
|
@ -125,6 +127,13 @@ Deno.test("Test Assert Match", () => {
|
|||
assertMatch("https://www.google.com", basicUrl);
|
||||
assertMatch("http://facebook.com", basicUrl);
|
||||
});
|
||||
|
||||
Deno.test("Test Assert Not Match", () => {
|
||||
assertNotMatch("abcdefghi", new RegExp("jkl"));
|
||||
|
||||
const basicUrl = new RegExp("^https?://[a-z.]+.com$");
|
||||
assertNotMatch("https://deno.land/", basicUrl);
|
||||
});
|
||||
```
|
||||
|
||||
### Throws
|
||||
|
|
Loading…
Add table
Reference in a new issue