-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jest-config): add reusable config (#652)
- Loading branch information
Showing
10 changed files
with
21,149 additions
and
12,200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.d.ts | ||
*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.gitignore | ||
node_modules | ||
project.json | ||
jest.config.ts | ||
jest-preset.ts | ||
tsconfig.lib.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# @taiga-ui/jest-config | ||
|
||
Common Jest configuration for taiga-ui projects | ||
|
||
## Usage | ||
|
||
1. Install from npm | ||
|
||
```bash | ||
npm i --save-dev @taiga-ui/jest-config | ||
``` | ||
|
||
2. Add to `package.json` | ||
|
||
```json | ||
{ | ||
"jest": { | ||
"preset": "@taiga-ui/jest-config" | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const preset = require(require('node:path').resolve(__dirname, './jest.config.js')); | ||
|
||
export default preset; | ||
|
||
/** | ||
* Should be here because | ||
* SyntaxError: Unexpected token 'export' | ||
* Jest encountered an unexpected token | ||
*/ | ||
module.exports = preset; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/// <reference lib="es2021" /> | ||
import {resolve} from 'node:path'; | ||
|
||
import type {JestConfigWithTsJest} from 'ts-jest'; | ||
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(process.cwd(), 'tsconfig.json')); | ||
const maxParallel = require('node:os').cpus().length / 2; | ||
|
||
export default { | ||
rootDir: process.cwd(), | ||
preset: 'jest-preset-angular', | ||
testEnvironment: 'jsdom', | ||
setupFilesAfterEnv: [ | ||
resolve(process.cwd(), './node_modules/@taiga-ui/testing/setup-jest/index.ts'), | ||
], | ||
extensionsToTreatAsEsm: ['.ts'], | ||
transform: { | ||
'^.+\\.(ts|js|mjs|html|svg)$': [ | ||
'jest-preset-angular', | ||
{ | ||
tsconfig: resolve(process.cwd(), 'tsconfig.spec.json'), | ||
stringifyContentPathRegex: String.raw`\.html$`, | ||
isolatedModules: true, | ||
diagnostics: true, | ||
}, | ||
], | ||
}, | ||
transformIgnorePatterns: [ | ||
String.raw`node_modules/(?!@angular|rxjs|ngx-highlightjs|@maskito|@ng-web-apis|@taiga-ui\/event-plugins|@taiga-ui\/polymorpheus)`, | ||
], | ||
testMatch: ['<rootDir>/projects/**/*.spec.ts'], | ||
testPathIgnorePatterns: ['/cypress/', '/playwright/', '/node_modules/'], | ||
coverageDirectory: '<rootDir>/coverage', | ||
collectCoverageFrom: ['<rootDir>/**/*.ts'], | ||
coveragePathIgnorePatterns: ['node_modules', 'schematics', '.spec.ts', '.cy.ts'], | ||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { | ||
prefix: `<rootDir>/${compilerOptions.baseUrl}/` | ||
.replaceAll('./', '/') | ||
.replaceAll(/\/\/+/g, '/'), | ||
}), | ||
modulePathIgnorePatterns: ['.cache', 'dist', '<rootDir>/dist/'], | ||
coverageReporters: ['lcov', 'clover'], | ||
cacheDirectory: '<rootDir>/node_modules/.cache/jest', | ||
maxConcurrency: maxParallel, | ||
maxWorkers: maxParallel, | ||
verbose: !process.env.CI, | ||
bail: 1, | ||
reporters: ['default'], | ||
passWithNoTests: true, | ||
collectCoverage: true, | ||
} satisfies JestConfigWithTsJest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@taiga-ui/jest-config", | ||
"version": "0.222.5", | ||
"description": "Taiga UI jest config", | ||
"keywords": [ | ||
"jest", | ||
"prettier" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/taiga-family/configurations.git" | ||
}, | ||
"license": "Apache-2.0", | ||
"main": "jest.config.js", | ||
"types": "jest.config.d.ts", | ||
"peerDependencies": { | ||
"@taiga-ui/testing": ">=4.10.0", | ||
"@types/jest": ">=29.5.13", | ||
"jest": ">=29.7.0", | ||
"jest-preset-angular": ">=14.2.4", | ||
"ts-jest": ">=29.2.5" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "jest-config", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"prefix": "tui", | ||
"projectType": "library", | ||
"sourceRoot": "projects/jest-config", | ||
"targets": { | ||
"build": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "npx tsc -p {projectRoot}/tsconfig.lib.json" | ||
} | ||
}, | ||
"publish": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "npm publish ./projects/{projectName} --access=public --ignore-scripts" | ||
}, | ||
"dependsOn": [ | ||
{ | ||
"target": "build", | ||
"params": "ignore", | ||
"dependencies": false | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["./*.ts"], | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"baseUrl": ".", | ||
"outDir": ".", | ||
"target": "es6", | ||
"module": "commonjs", | ||
"declaration": true, | ||
"incremental": null, | ||
"verbatimModuleSyntax": false, | ||
"types": ["node", "jest"] | ||
} | ||
} |