Function createAssertSnapshot
- create
Assert <T>(options, baseAssertSnapshot?): typeof assertSnapshotSnapshot Type Parameters
Parameters
- options: SnapshotOptions<T>
The options
- baseAssertSnapshot: {
<T>(context: TestContext, actual: T, options: SnapshotOptions<T>): Promise<void>;
<T>(context: TestContext, actual: T, message?: string): Promise<void>;
} = assertSnapshotassertSnapshotfunction implementation. Default to the originalassertSnapshot- <T>(context, actual, options): Promise<void>
Make an assertion that
actualmatches a snapshot. If the snapshot andactualdo not match, then throw.Type parameter can be specified to ensure values under comparison have the same type.
Type Parameters
Parameters
- context: TestContext
The test context
- actual: T
The actual value to compare
- options: SnapshotOptions<T>
The options
Returns Promise<void>
- context: TestContext
- <T>(context, actual, message?): Promise<void>
Make an assertion that
actualmatches a snapshot. If the snapshot andactualdo not match, then throw.Type parameter can be specified to ensure values under comparison have the same type.
Type Parameters
Parameters
- context: TestContext
The test context
- actual: T
The actual value to compare
Optionalmessage: stringThe optional assertion message
Returns Promise<void>
- context: TestContext
Returns typeof assertSnapshot
assertSnapshotfunction with the given default options.Example: Usage
import { createAssertSnapshot } from "@std/testing/snapshot";
const assertSnapshot = createAssertSnapshot({
// Uses the custom directory for saving snapshot files.
dir: "my_snapshot_dir",
});
Deno.test("a snapshot test case", async (t) => {
await assertSnapshot(t, {
foo: "Hello",
bar: "World",
});
})- options: SnapshotOptions<T>
Create
assertSnapshotfunction with the given options.The specified option becomes the default for returned
assertSnapshot