-
-
Notifications
You must be signed in to change notification settings - Fork 671
Expand file tree
/
Copy pathjest.config.js
More file actions
59 lines (56 loc) · 2.19 KB
/
Copy pathjest.config.js
File metadata and controls
59 lines (56 loc) · 2.19 KB
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
/*
* Silex website builder, free/libre no-code tool for makers.
* Copyright (c) 2023 lexoyo and Silex Labs foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Monorepo single-package layout: map the ~/ path aliases (mirror of tsconfig "paths")
// and the grapesjs-* plugin sources so jest resolves them like webpack/tsc do.
const moduleNameMapper = {
'^(\\.{1,2}/.*)\\.js$': '$1',
'^~/common$': '<rootDir>/common',
'^~/common/(.*?)(?:\\.js)?$': '<rootDir>/common/$1',
'^~/editor/(.*?)(?:\\.js)?$': '<rootDir>/editor/$1',
'^~/server/(.*?)(?:\\.js)?$': '<rootDir>/server/$1',
'^~/grapesjs-plugins/(.*)$': '<rootDir>/grapesjs-plugins/$1',
'^@silexlabs/expression-input$': '<rootDir>/grapesjs-plugins/expression-input/src/index.ts',
'^@silexlabs/grapesjs-([^/]+)$': '<rootDir>/grapesjs-plugins/grapesjs-$1/src/index',
}
const transform = {
// isolatedModules: transpile-only, no type-checking during tests.
// Type-checking is a separate CI step (tsc/lint), like the webpack build.
'.ts': ['ts-jest', { useESM: true, isolatedModules: true }],
}
const common = {
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper,
transform,
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
}
module.exports = {
projects: [
{
...common,
displayName: 'dom',
testEnvironment: 'jsdom',
testEnvironmentOptions: { url: 'http://localhost:6800/' },
testMatch: ['<rootDir>/editor/**/*.test.ts'],
},
{
...common,
displayName: 'node',
testEnvironment: 'node',
testMatch: ['<rootDir>/server/**/*.test.ts', '<rootDir>/common/**/*.test.ts'],
},
],
}