Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// https://jestjs.io/docs/en/configuration
// Configuring Jest
const path = require('path');
const { pathsToModuleNameMapper: resolver } = require('ts-jest/utils');
const { compilerOptions } = require('./tsconfig');
const moduleNameMapper = resolver(compilerOptions.paths, { prefix: '/' });
const CI = process.env['CI'] === 'true';
if (!CI) {
console.log('[DEBUG]: moduleNameMapper');
console.log(JSON.stringify(moduleNameMapper, null, 4));
}
module.exports = {
displayName: 'ngxs',
projects: [''],
rootDir: path.resolve('.'),
/**
* A set of global variables that need to be available in all test environments.
*/
globals: {
/* eslint-disable import/no-extraneous-dependencies */
const { defaults: tsjPreset } = require('ts-jest/presets');
// 🔰 Tips, if `tsconfig.json`, here will be open
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { compilerOptions } = require('./tsconfig');
module.exports = {
transform: {
...tsjPreset.transform,
'^.+\\.tsx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js'],
//
// 🔰 Tips, if `tsconfig.json`, here will be open
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '/' }),
//
modulePathIgnorePatterns: ['/_dist/', '/_deploy/'],
testRegex: 'src.*\\.(test|spec).(ts|tsx|js)$',
collectCoverageFrom: [
'src/**/*.{js,jsx,tsx,ts}',
'!**/node_modules/**',
'!**/vendor/**',
'!**/dist/**',
'!**/_dist/**',
'!**/_deploy/**',
],
// coverageReporters: ['json', 'lcov'],
testEnvironment: 'node',
collectCoverage: true,
// coverageDirectory: './coverage',
};
/* eslint-disable import/no-commonjs, functional/immutable-data */
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { compilerOptions } = require('./tsconfig');
const config = {
testMatch: ['**/__tests__/**/*.test.ts'],
preset: 'ts-jest',
setupFilesAfterEnv: ['config/jest.js', 'jest-mock-console/dist/setupTestFramework.js'],
transform: {
'^.+\\.ts?$': 'ts-jest',
},
moduleFileExtensions: ['js', 'ts'],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '/' }),
transformIgnorePatterns: [],
coverageReporters: ['text'],
collectCoverage: true,
collectCoverageFrom: ['**/src*/*.ts', '!**/src/__tests__/*.ts'],
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
};
module.exports = {
projects: [
paths: {
"@/*": ["./*"],
},
},
}
const { compilerOptions } = tsPathConfig
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testPathIgnorePatterns: ["/test/", "/node_modules/", "lib"],
moduleDirectories: ["node_modules", "src"],
moduleNameMapper: {
"^.+\\.(css|less|scss)$": "identity-obj-proxy",
...pathsToModuleNameMapper(compilerOptions.paths, { prefix: "/" }),
"\\.svg": "/src/__mocks__/filemock.tsx",
},
globals: {
// All globals should be in upper case due webpack configuration
DEVELOPMENT: true,
},
}
"tsx",
"js",
"jsx",
"json",
"node"
],
"roots": [
""
],
"modulePathIgnorePatterns": ["/example"],
"globals": {
"ts-jest": {
"tsConfig": "./tsconfig.json"
}
},
"moduleNameMapper": pathsToModuleNameMapper(compilerOptions.paths /*, { prefix: '/' } */),
"modulePaths": [
""
],
"testEnvironment": "jsdom",
"setupFiles": [
"./setupTests.ts"
],
"setupFilesAfterEnv": ["/setupTests.ts"]
};
function getModuleNameMapper(paths) {
if (!paths) return
const map = pathsToModuleNameMapper(paths)
for (const key in map) {
map[key] = map[key].replace('./', '/')
}
return map
}
displayName: 'client',
roots: ['/app'],
preset: 'jest-preset-angular',
globals: {
'ts-jest': {
tsConfigFile: './tsconfig.spec.json'
},
__TRANSFORM_HTML__: true
},
transform: {
'^.+\\.(ts|js|html)$':
'/../../node_modules/jest-preset-angular/preprocessor.js'
},
testMatch: ['**/*.spec.ts'],
moduleFileExtensions: ['ts', 'js', 'json', 'html'],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {prefix: '/'}),
transformIgnorePatterns: ['node_modules/(?!@ngrx)'],
snapshotSerializers: [
'/../../node_modules/jest-preset-angular/AngularSnapshotSerializer.js',
'/../../node_modules/jest-preset-angular/HTMLCommentSerializer.js'
],
setupFilesAfterEnv: ['/setupJest.ts'],
coverageDirectory: '/../../coverage/client'
}
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { compilerOptions } = require('./tsconfig');
module.exports = {
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '/',
}),
roots: ['/src'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
};
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { compilerOptions } = require('./tsconfig');
module.exports = {
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '/',
}),
roots: ['/src'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
};
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const path = require('path')
const { mapValues } = require('lodash')
const { compilerOptions } = require('./packages/tsconfig.test');
const projectDefault = {
moduleNameMapper: mapValues(pathsToModuleNameMapper(compilerOptions.paths), v => path.resolve(path.join('packages', v))),
testEnvironment: 'node',
transform: {
'^.+\\.(ts)$': 'ts-jest',
}
};
module.exports = {
projects: [
{
...projectDefault,
displayName: 'HTTP-SERVER',
testMatch: ['/packages/http-server/src/**/__tests__/*.*.ts'],
globals: {
'ts-jest': {
tsConfig: '/packages/tsconfig.test.json',
},