-
Notifications
You must be signed in to change notification settings - Fork 48
/
jest.config.js
47 lines (47 loc) · 1.75 KB
/
jest.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
export default {
/* Run tests in a normal Node environment, not a fake browser (JSDOM)
* environment. This is a Node app after all. But this also fixes an
* long-known issue where Jest breaks the Node stdlib by providing a Buffer
* that's not a subclass of Uint8Array, see:
*
* https://github.com/facebook/jest/issues/4422
*
* This subclass relationship is relied on by many things dealing with
* Buffers and typed arrays, including the @aws-crypto/… libraries.
*
* A suggested workaround from the issue discussion is to add:
*
* globals: {"Uint8Array": Uint8Array}
*
* to the Jest config, and at first this appears to work if you run a single
* affected test file. However, it doesn't work when running multiple test
* files unless the --runInBand option is also used, implicating the worker
* subprocess system.
*
* The Jest config docs give a clue here:
*
* In addition, the globals object must be json-serializable, so it can't
* be used to specify global functions…
*
* This means the workaround above shouldn't be expected to work at all, even
* though it happens to work for single test files (presumably because
* they're run in the same process and thus skip serialization so the value
* is preserved?).
*
* Adding to the confusion, Node is the default testEnvironment for recent
* versions of Jest (at least 28.x), but not the version we're using here
* (26.x). Being explicit won't hurt when we upgrade, but this difference
* led me astray for a bit.
* -trs, 20 May 2022
*/
testEnvironment: "node",
testMatch: [
"**/*.test.js"
],
globals: {
BASE_URL: "http://localhost:5000"
},
setupFilesAfterEnv: [
"jest-extended/all"
]
};