first commit
Some checks failed
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Some checks failed
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
68
jest.config.js
Normal file
68
jest.config.js
Normal file
@@ -0,0 +1,68 @@
|
||||
const { pathsToModuleNameMapper } = require('ts-jest');
|
||||
const { compilerOptions } = require('get-tsconfig').getTsconfig().config;
|
||||
const { resolve } = require('path');
|
||||
|
||||
/** @type {import('ts-jest').TsJestGlobalOptions} */
|
||||
const tsJestOptions = {
|
||||
isolatedModules: true,
|
||||
tsconfig: {
|
||||
...compilerOptions,
|
||||
declaration: false,
|
||||
sourceMap: true,
|
||||
},
|
||||
};
|
||||
|
||||
const isCoverageEnabled = process.env.COVERAGE_ENABLED === 'true';
|
||||
|
||||
const esmDependencies = [
|
||||
'pdfjs-dist',
|
||||
'openid-client',
|
||||
'oauth4webapi',
|
||||
'jose',
|
||||
'p-retry',
|
||||
'is-network-error',
|
||||
// Add other ESM dependencies that need to be transformed here
|
||||
];
|
||||
|
||||
const esmDependenciesPattern = esmDependencies.join('|');
|
||||
const esmDependenciesRegex = `node_modules/(${esmDependenciesPattern})/.+\\.m?js$`;
|
||||
|
||||
/** @type {import('jest').Config} */
|
||||
const config = {
|
||||
verbose: true,
|
||||
testEnvironment: 'node',
|
||||
testRegex: '\\.(test|spec)\\.(js|ts)$',
|
||||
testPathIgnorePatterns: ['/dist/', '/node_modules/'],
|
||||
transform: {
|
||||
'^.+\\.ts$': ['ts-jest', tsJestOptions],
|
||||
[esmDependenciesRegex]: [
|
||||
'babel-jest',
|
||||
{
|
||||
presets: ['@babel/preset-env'],
|
||||
plugins: ['babel-plugin-transform-import-meta'],
|
||||
},
|
||||
],
|
||||
},
|
||||
transformIgnorePatterns: [`/node_modules/(?!${esmDependenciesPattern})/`],
|
||||
// This resolve the path mappings from the tsconfig relative to each jest.config.js
|
||||
moduleNameMapper: {
|
||||
'^@n8n/utils$': resolve(__dirname, 'packages/@n8n/utils/dist/index.cjs'),
|
||||
...(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;
|
||||
Reference in New Issue
Block a user