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
@@ -12,7 +12,41 @@ Article PRs should be reviewed using the [PR review process here](https://github
12
12
13
13
### Creating tests
14
14
15
-
Test files must be within `/src`, with a file name ending in `.test.<ext>`, where `<ext>` is one of `js``mjs``jsx``ts``tsx`.
15
+
1. For some module `foo.js`, create a file `foo.test.js` in the same directory.
16
+
17
+
-`.ts` / `.mjs` / `.js` are all valid extensions.
18
+
-`.tsx` / `.jsx` are permitted, though unless the XML syntax is necessary, use `.ts` / `.mjs` instead.
19
+
- Tests must be within `/src`.
20
+
21
+
2. Import the module to be tested.
22
+
23
+
- For TypeScript, Jest utilities are not in global scope, so you will need to import these from `@jest/globals`.
24
+
25
+
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.
26
+
27
+
```ts
28
+
/**@file criticalMathModule.test.ts */
29
+
import { describe, expect, it } from"@jest/globals"; // only needed for TypeScript
0 commit comments