Skip to content

Commit

Permalink
Add test style guide (denoland#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
zekth authored and ry committed Mar 15, 2019
1 parent 62761a4 commit 23108b0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions website/style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,30 @@ the first column of the comment. For example:

Code examples should not contain additional comments. It is already inside a
comment. If it needs further comments is not a good example.

## Each module should come with tests

Each module should come with its test as a sibling with the name
`modulename_test.ts`. For example the module `foo.ts` should come with its
sibling `foo_test.ts`.

## Unit Tests should be explicit

For a better understanding of the tests, function should be correctly named as
its prompted throughout the test command. Like:

```
test myTestFunction ... ok
```

Example of test:

```ts
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { test } from "https://deno.land/[email protected]/testing/mod.ts";
import { foo } from "./mod.ts";

test(function myTestFunction() {
assertEquals(foo(), { bar: "bar" });
});
```

0 comments on commit 23108b0

Please sign in to comment.