/* * 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 . */ // 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$': '/common', '^~/common/(.*?)(?:\\.js)?$': '/common/$1', '^~/editor/(.*?)(?:\\.js)?$': '/editor/$1', '^~/server/(.*?)(?:\\.js)?$': '/server/$1', '^~/grapesjs-plugins/(.*)$': '/grapesjs-plugins/$1', '^@silexlabs/expression-input$': '/grapesjs-plugins/expression-input/src/index.ts', '^@silexlabs/grapesjs-([^/]+)$': '/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: ['/editor/**/*.test.ts'], }, { ...common, displayName: 'node', testEnvironment: 'node', testMatch: ['/server/**/*.test.ts', '/common/**/*.test.ts'], }, ], }