-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
.jestSetup.js
34 lines (29 loc) · 945 Bytes
/
.jestSetup.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
process.env.GATSBY_SHOULD_TRACK_IMAGE_CDN_URLS = "true"
// See https://github.com/inrupt/solid-client-authn-js/issues/1676
if (
typeof globalThis.TextEncoder === "undefined" ||
typeof globalThis.TextDecoder === "undefined"
) {
const utils = require("util")
globalThis.TextEncoder = utils.TextEncoder
globalThis.TextDecoder = utils.TextDecoder
}
jest.mock(`gatsby-worker`, () => {
const gatsbyWorker = jest.requireActual(`gatsby-worker`)
const { WorkerPool: OriginalWorkerPool } = gatsbyWorker
class WorkerPoolThatCanUseTS extends OriginalWorkerPool {
constructor(workerPath, options) {
options.env = {
...(options.env ?? {}),
NODE_OPTIONS: `--require ${require.resolve(
`./packages/gatsby/src/utils/worker/__tests__/test-helpers/ts-register.js`
)}`,
}
super(workerPath, options)
}
}
return {
...gatsbyWorker,
WorkerPool: WorkerPoolThatCanUseTS,
}
})