forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test style guide (denoland#1918)
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" }); | ||
}); | ||
``` |