mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -08:00
34df8b6238
Co-authored-by: Csaba Tuncsik <[email protected]>
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
const { compilerOptions } = require('./tsconfig.json');
|
|
|
|
const tsJestOptions = {
|
|
isolatedModules: true,
|
|
tsconfig: {
|
|
...compilerOptions,
|
|
declaration: false,
|
|
sourceMap: true,
|
|
},
|
|
};
|
|
|
|
const { baseUrl, paths } = require('get-tsconfig').getTsconfig().config?.compilerOptions;
|
|
|
|
/** @type {import('jest').Config} */
|
|
const config = {
|
|
verbose: true,
|
|
testEnvironment: 'node',
|
|
testRegex: '\\.(test|spec)\\.(js|ts)$',
|
|
testPathIgnorePatterns: ['/dist/', '/node_modules/'],
|
|
transform: {
|
|
'^.+\\.ts$': ['ts-jest', tsJestOptions],
|
|
},
|
|
// This resolve the path mappings from the tsconfig relative to each jest.config.js
|
|
moduleNameMapper: Object.entries(paths || {}).reduce((acc, [path, [mapping]]) => {
|
|
path = `^${path.replace(/\/\*$/, '/(.*)$')}`;
|
|
mapping = mapping.replace(/^\.\/(?:(.*)\/)?\*$/, '$1');
|
|
mapping = mapping ? `/${mapping}` : '';
|
|
acc[path] = '<rootDir>' + (baseUrl ? `/${baseUrl.replace(/^\.\//, '')}` : '') + mapping + '/$1';
|
|
return acc;
|
|
}, {}),
|
|
setupFilesAfterEnv: ['jest-expect-message'],
|
|
collectCoverage: true,
|
|
coverageReporters: [process.env.COVERAGE_REPORT === 'true' ? 'text' : 'text-summary'],
|
|
collectCoverageFrom: ['src/**/*.ts'],
|
|
};
|
|
|
|
if (process.env.CI === 'true') {
|
|
config.workerIdleMemoryLimit = 1024;
|
|
config.coverageReporters = ['cobertura'];
|
|
}
|
|
|
|
module.exports = config;
|