Skip to content

Commit

Permalink
ci: add jest
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Oct 26, 2023
1 parent f5c5d39 commit e284d22
Show file tree
Hide file tree
Showing 13 changed files with 2,502 additions and 1,573 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ testem.log
# System Files
.DS_Store
Thumbs.db

.nx
.angular
45 changes: 45 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {Config} from 'jest';
import {resolve} from 'path';
import {pathsToModuleNameMapper} from 'ts-jest';

process.env.TZ = `Europe/Moscow`;
process.env.FORCE_COLOR = `true`;
process.env.TS_JEST_DISABLE_VER_CHECKER = `true`;

const {compilerOptions} = require(resolve(__dirname, `tsconfig.json`));

const config: Config = {
rootDir: __dirname,
preset: `jest-preset-angular`,
testEnvironment: `jsdom`,
globals: {
'ts-jest': {
tsconfig: resolve(__dirname, `tsconfig.spec.json`),
isolatedModules: true,
},
},
extensionsToTreatAsEsm: [`.ts`],
setupFilesAfterEnv: [`<rootDir>/setup-jest.ts`],
transform: {'^.+\\.(ts|js|mjs|html|svg)$': `jest-preset-angular`},
testMatch: [`<rootDir>/projects/**/*.spec.ts`],
testPathIgnorePatterns: [`/node_modules/`, `/schematics/`],
coverageDirectory: `<rootDir>/coverage`,
collectCoverageFrom: [
`**/ng-polymorpheus/**/*.ts`,
`!**/ng-polymorpheus/**/*.spec.ts`,
`!**/jest.config.ts`,
],
coveragePathIgnorePatterns: [`node_modules`, `schematics`, `.spec.ts`],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: `<rootDir>/${compilerOptions.baseUrl}/`
.replace(/\.\//g, `/`)
.replace(/\/\/+/g, `/`),
}),
modulePathIgnorePatterns: [`dist/`],
cacheDirectory: `<rootDir>/node_modules/.cache/jest`,
reporters: [`default`],
collectCoverage: true,
verbose: true,
};

export default config;
30 changes: 16 additions & 14 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
{
"npmScope": "ng-polymorpheus",
"tasksRunnerOptions": {
"default": {
"runner": "nx-cloud",
"options": {
"parallel": 1,
"cacheableOperations": ["build", "test", "lint"]
}
}
},
"affected": {
"defaultBase": "origin/main"
},
Expand All @@ -20,14 +10,26 @@
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"sharedGlobals": ["{workspaceRoot}/nx.json", "{workspaceRoot}/tsconfig.*.json", "{workspaceRoot}/tsconfig.json"]
"sharedGlobals": [
"{workspaceRoot}/nx.json",
"{workspaceRoot}/tsconfig.*.json",
"{workspaceRoot}/tsconfig.json"
],
"production": ["default"]
},
"targetDefaults": {
"build": {
"inputs": ["default"]
"inputs": ["default"],
"cache": true
},
"test": {
"inputs": ["default"]
"inputs": ["default"],
"cache": true
},
"lint": {
"cache": true
}
}
},
"parallel": 1,
"nxCloudAccessToken": "YTM0YzgyN2UtMjU1Ny00ZTIwLWFhYmUtMjYyYzZhOTIzOTJifHJlYWQtd3JpdGU="
}
Loading

0 comments on commit e284d22

Please sign in to comment.