Skip to content

Commit

Permalink
docs(testing): improve the docs of @std/testing (#5033)
Browse files Browse the repository at this point in the history
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
  • Loading branch information
kt3k and iuioiua committed Jun 17, 2024
1 parent 3754e8a commit 635e062
Show file tree
Hide file tree
Showing 9 changed files with 1,591 additions and 77 deletions.
8 changes: 7 additions & 1 deletion _tools/check_docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ const ENTRY_POINTS = [
"../semver/mod.ts",
"../streams/mod.ts",
"../text/mod.ts",
"../testing/bdd.ts",
"../testing/mock.ts",
"../testing/snapshot.ts",
"../testing/time.ts",
"../testing/types.ts",
"../toml/mod.ts",
"../ulid/mod.ts",
"../url/mod.ts",
Expand All @@ -67,7 +72,8 @@ const ENTRY_POINTS = [
] as const;

const TS_SNIPPET = /```ts[\s\S]*?```/g;
const ASSERTION_IMPORT = /import \{.*\} from "@std\/assert(?:\/.*)?";/gm;
const ASSERTION_IMPORT =
/from "@std\/(assert(\/[a-z-]+)?|testing\/(mock|snapshot|types))"/g;
const NEWLINE = "\n";
const diagnostics: DocumentError[] = [];
const snippetPromises: Promise<void>[] = [];
Expand Down
7 changes: 7 additions & 0 deletions testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This package provides utilities for testing.

- [BDD style testing](https://jsr.io/@std/testing/doc/bdd/~)
- [Test doubles (mocking)](https://jsr.io/@std/testing/doc/mock/~)
- [Faking time and timers](https://jsr.io/@std/testing/doc/time/~)
- [Snapshot testing](https://jsr.io/@std/testing/doc/snapshot/~)
- [Type assertions](https://jsr.io/@std/testing/doc/types/~)
3 changes: 3 additions & 0 deletions testing/_test_suite.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
/** The options for creating a test suite with the describe function. */
export interface DescribeDefinition<T> extends Omit<Deno.TestDefinition, "fn"> {
/** The body of the test suite */
fn?: () => void;
/**
* The `describe` function returns a `TestSuite` representing the group of tests.
Expand Down Expand Up @@ -28,6 +29,7 @@ export interface DescribeDefinition<T> extends Omit<Deno.TestDefinition, "fn"> {

/** The options for creating an individual test case with the it function. */
export interface ItDefinition<T> extends Omit<Deno.TestDefinition, "fn"> {
/** The body of the test case */
fn: (this: T, t: Deno.TestContext) => void | Promise<void>;
/**
* The `describe` function returns a `TestSuite` representing the group of tests.
Expand Down Expand Up @@ -62,6 +64,7 @@ const optionalTestStepDefinitionKeys: (keyof Deno.TestStepDefinition)[] = [
* A group of tests.
*/
export interface TestSuite<T> {
/** The symbol to use for grouping the test suite */
symbol: symbol;
}

Expand Down
Loading

0 comments on commit 635e062

Please sign in to comment.