f
Deno.bench
Register a benchmark test which will be run when `deno bench` is used on
the command line and the containing module looks like a bench module.
If the test function (`fn`) returns a promise or is async, the test runner
will await resolution to consider the test complete.
```ts
import { assertEquals } from "jsr:@std/assert";
Deno.bench({
name: "example test",
fn() {
assertEquals("world", "world");
},
});
Deno.bench({
name: "example ignored test",
ignore: Deno.build.os === "windows",
fn() {
// This test is ignored only on Windows machines
},
});
Deno.bench({
name: "example async test",
async fn() {
const decoder = new TextDecoder("utf-8");
const data = await Deno.readFile("hello_world.txt");
assertEquals(decoder.decode(data), "Hello world");
}
});
```
I
Deno.BenchContext
Context that is passed to a benchmarked function. The instance is shared
between iterations of the benchmark. Its methods can be used for example
to override of the measured portion of the function.
I
Deno.BenchDefinition
The interface for defining a benchmark test using [`Deno.bench`](./././~/Deno.bench).
I
I
Deno.TestContext
Context that is passed to a testing function, which can be used to either
gain information about the current test, or register additional test
steps within the current test.
I
Deno.TestDefinition
No documentation available
I
Deno.TestStepDefinition
No documentation available
v
Deno.test
Register a test which will be run when `deno test` is used on the command
line and the containing module looks like a test module.
`fn` can be async if required.
```ts
import { assertEquals } from "jsr:@std/assert";
Deno.test({
name: "example test",
fn() {
assertEquals("world", "world");
},
});
Deno.test({
name: "example ignored test",
ignore: Deno.build.os === "windows",
fn() {
// This test is ignored only on Windows machines
},
});
Deno.test({
name: "example async test",
async fn() {
const decoder = new TextDecoder("utf-8");
const data = await Deno.readFile("hello_world.txt");
assertEquals(decoder.decode(data), "Hello world");
}
});
```