Files
n8n-enterprise-unlocked/jest.config.js
कारतोफ्फेलस्क्रिप्ट™ b772462cea chore: Upgrade pdfjs-dist (no-changelog) (#15729)
2025-06-04 18:31:22 +02:00

52 lines
1.5 KiB
JavaScript

const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('get-tsconfig').getTsconfig().config;
/** @type {import('ts-jest').TsJestGlobalOptions} */
const tsJestOptions = {
isolatedModules: true,
tsconfig: {
...compilerOptions,
declaration: false,
sourceMap: true,
},
};
const isCoverageEnabled = process.env.COVERAGE_ENABLED === 'true';
/** @type {import('jest').Config} */
const config = {
verbose: true,
testEnvironment: 'node',
testRegex: '\\.(test|spec)\\.(js|ts)$',
testPathIgnorePatterns: ['/dist/', '/node_modules/'],
transform: {
'^.+\\.ts$': ['ts-jest', tsJestOptions],
'node_modules/pdfjs-dist/.+\\.mjs$': [
'babel-jest',
{
presets: ['@babel/preset-env'],
plugins: ['babel-plugin-transform-import-meta'],
},
],
},
transformIgnorePatterns: ['/dist/', '/node_modules/(?!.*pdfjs-dist/)'],
// This resolve the path mappings from the tsconfig relative to each jest.config.js
moduleNameMapper: compilerOptions?.paths
? pathsToModuleNameMapper(compilerOptions.paths, {
prefix: `<rootDir>${compilerOptions.baseUrl ? `/${compilerOptions.baseUrl.replace(/^\.\//, '')}` : ''}`,
})
: {},
setupFilesAfterEnv: ['jest-expect-message'],
collectCoverage: isCoverageEnabled,
coverageReporters: ['text-summary', 'lcov', 'html-spa'],
workerIdleMemoryLimit: '1MB',
};
if (process.env.CI === 'true') {
config.collectCoverageFrom = ['src/**/*.ts'];
config.reporters = ['default', 'jest-junit'];
config.coverageReporters = ['cobertura'];
}
module.exports = config;