Skip to content

Commit

Permalink
feat(jest-config): add reusable config
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Oct 11, 2024
1 parent 1e6a177 commit e210626
Show file tree
Hide file tree
Showing 8 changed files with 21,138 additions and 12,200 deletions.
33,184 changes: 20,984 additions & 12,200 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions projects/jest-config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jest.config.d.ts
jest.config.js
5 changes: 5 additions & 0 deletions projects/jest-config/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gitignore
node_modules
project.json
jest.config.ts
tsconfig.lib.json
22 changes: 22 additions & 0 deletions projects/jest-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# @taiga-ui/stylelint-config

Common Stylelint configuration for taiga-ui projects

## Usage

1. Install from npm

```bash
npm i --save-dev @taiga-ui/stylelint-config
```

2. Create `stylelint.config.js` at project root

```json5
{
extends: ['@taiga-ui/stylelint-config/taiga'],
}
```

More information about available at
[stylelint documentation](https://github.com/stylelint/stylelint/blob/main/docs/user-guide/configure.md)
56 changes: 56 additions & 0 deletions projects/jest-config/jest.config.ts
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;
26 changes: 26 additions & 0 deletions projects/jest-config/package.json
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"
}
}
28 changes: 28 additions & 0 deletions projects/jest-config/project.json
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
}
]
}
}
}
15 changes: 15 additions & 0 deletions projects/jest-config/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.json",
"include": ["./jest.config.ts"],
"compilerOptions": {
"rootDir": ".",
"baseUrl": ".",
"outDir": ".",
"target": "es6",
"module": "commonjs",
"declaration": true,
"incremental": null,
"verbatimModuleSyntax": false,
"types": ["node", "jest"]
}
}

0 comments on commit e210626

Please sign in to comment.