-
Notifications
You must be signed in to change notification settings - Fork 10
/
jest.config.js
61 lines (57 loc) · 1.99 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const path = require('path');
const dotenv = require('dotenv');
const loadEnv = envPath => {
try {
dotenv.config({ path: envPath });
} catch (err) {
// only ignore error if file is not found
if (err.toString().indexOf('ENOENT') < 0) {
throw err;
}
}
}
// Contrary to what you'd expect, the first env loaded is the one whose values are kept
loadEnv(path.join(__dirname, './.env.local'));
loadEnv(path.join(__dirname, './.env'));
function getEngineLocation() {
switch (process.env.ENGINE_LOCATION) {
case 'local':
return path.resolve(__dirname, './src/eterna/folding/engines');
case 'package':
return 'eternajs-folding-engines/engines';
default:
throw new Error('Invalid engine location');
}
}
module.exports = {
"preset": "ts-jest/presets/default-esm",
"moduleDirectories": [
"node_modules",
"src",
"<rootDir>"
],
"moduleNameMapper": {
"\\.(css|less)$": "assets/__mocks__/styleMock.js",
"engines-bin/(.*)": `${getEngineLocation()}/$1`,
'^(\\.{1,2}/.*)\\.js$': '$1'
},
"transform": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|onnx|wasm)$": "<rootDir>/../assets/__mocks__/fileTransformer.js",
},
"transformIgnorePatterns": ["/node_modules/.*(?<!\.onnx)$"],
"rootDir": "src",
"testRegex": "/__tests__/.*\\.test\\.(ts|tsx|js)$",
"setupFiles": [
"jest-canvas-mock",
"dotenv/config"
],
"testEnvironment": "jsdom",
"testEnvironmentOptions": {
// If a dependency states that it has environments for different runtimes, we choose to
// load the node version (vs the browser version). In particular this is relevant for onnxruntime,
// in which the browser bundle will auto-detect it is running in a node environment and use
// codepaths which don't actually work (we could work around that with a custom environment
// but that seems more brittle)
"customExportConditions": ["node"],
}
}