You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+35-1
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,40 @@ This document builds on the [default contributing.md](https://github.com/comcode
10
10
11
11
### Creating tests
12
12
13
-
Test files must be within `/src`, with a file name ending in `.test.<ext>`, where `<ext>` is one of `js``mjs``jsx``ts``tsx`.
13
+
1. For some module `foo.js`, create a file `foo.test.js` in the same directory.
14
+
15
+
-`.ts` / `.mjs` / `.js` are all valid extensions.
16
+
-`.tsx` / `.jsx` are permitted, though unless the XML syntax is necessary, use `.ts` / `.mjs` instead.
17
+
- Tests must be within `/src`.
18
+
19
+
2. Import the module to be tested.
20
+
21
+
- For TypeScript, Jest utilities are not in global scope, so you will need to import these from `@jest/globals`.
22
+
23
+
3. Use Jest's [`expect`](https://jestjs.io/docs/expect), [`it`](https://jestjs.io/docs/api#testname-fn-timeout) and [`describe`](https://jestjs.io/docs/api#describename-fn) to organise and assert the behaviour of the module. A test name should start with a verb, and descriptions should be used to indicate what component is being tested.
24
+
25
+
```ts
26
+
/**@file criticalMathModule.test.ts */
27
+
import { describe, expect, it } from"@jest/globals"; // only needed for TypeScript
0 commit comments