mirror of
https://github.com/logto-io/logto.git
synced 2025-03-17 22:31:28 -05:00
feat(jest-config): init package (#644)
* feat(jest-config): init package * chore(deps): upgrade `@types/jest` * fix(core): add jest-matcher dependency add jest-matcher dependency Co-authored-by: simeng-li <simeng@silverhand.io>
This commit is contained in:
parent
fefe566044
commit
2d7918a224
9 changed files with 426 additions and 326 deletions
|
@ -1,18 +0,0 @@
|
|||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
setupFilesAfterEnv: ['./jest.setup.ts', 'jest-matcher-specific-error'],
|
||||
globalSetup: './jest.global-setup.ts',
|
||||
globals: {
|
||||
'ts-jest': {
|
||||
tsconfig: 'tsconfig.test.json',
|
||||
},
|
||||
},
|
||||
moduleNameMapper: {
|
||||
'^@/(.*)$': '<rootDir>/src/$1',
|
||||
'^jose/(.*)$': '<rootDir>/node_modules/jose/dist/node/cjs/$1',
|
||||
},
|
||||
coveragePathIgnorePatterns: ['/node_modules/', '/build/', '/src/__mocks__/'],
|
||||
coverageReporters: ['text-summary', 'lcov'],
|
||||
};
|
9
packages/core/jest.config.ts
Normal file
9
packages/core/jest.config.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { merge, Config } from '@logto/jest-config';
|
||||
|
||||
const config: Config.InitialOptions = merge({
|
||||
testEnvironment: 'node',
|
||||
setupFilesAfterEnv: ['jest-matcher-specific-error', './jest.setup.ts'],
|
||||
globalSetup: './jest.global-setup.ts',
|
||||
});
|
||||
|
||||
export default config;
|
|
@ -50,6 +50,7 @@
|
|||
"zod": "^3.14.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@logto/jest-config": "^0.1.0",
|
||||
"@shopify/jest-koa-mocks": "^3.0.8",
|
||||
"@silverhand/eslint-config": "^0.10.2",
|
||||
"@silverhand/ts-config": "^0.10.2",
|
||||
|
|
38
packages/jest-config/jest.config.ts
Normal file
38
packages/jest-config/jest.config.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import type { Config } from '@jest/types';
|
||||
import deepmerge from 'deepmerge';
|
||||
|
||||
const baseConfig: Config.InitialOptions = Object.freeze({
|
||||
preset: 'ts-jest',
|
||||
transform: {
|
||||
// Enable JS/JSX transformation
|
||||
'\\.(ts|js)x?$': 'ts-jest',
|
||||
'\\.(svg)$': 'jest-transform-stub',
|
||||
},
|
||||
transformIgnorePatterns: [
|
||||
'[/\\\\]node_modules[/\\\\]((?!ky[/\\\\]).)+\\.(js|jsx|mjs|cjs|ts|tsx)$',
|
||||
],
|
||||
moduleNameMapper: {
|
||||
// Map path alias in `tsconfig.json`
|
||||
'^@/(.*)$': '<rootDir>/src/$1',
|
||||
// Mock CSS Modules
|
||||
'\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
|
||||
// Explicitly point jose to cjs version
|
||||
'^jose/(.*)$': '<rootDir>/node_modules/jose/dist/node/cjs/$1',
|
||||
},
|
||||
coveragePathIgnorePatterns: ['/node_modules/', '/lib/', '/build/', '/src/__mocks__/'],
|
||||
coverageReporters: ['text-summary', 'lcov'],
|
||||
globals: {
|
||||
'ts-jest': {
|
||||
tsconfig: 'tsconfig.test.json',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default baseConfig;
|
||||
|
||||
export const merge = (
|
||||
config: Config.InitialOptions,
|
||||
mergeOptions?: deepmerge.Options
|
||||
): Config.InitialOptions => deepmerge(baseConfig, config, mergeOptions);
|
||||
|
||||
export type { Config } from '@jest/types';
|
47
packages/jest-config/package.json
Normal file
47
packages/jest-config/package.json
Normal file
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "@logto/jest-config",
|
||||
"version": "0.1.0",
|
||||
"main": "lib/jest.config.js",
|
||||
"repository": "https://github.com/logto-io/logto",
|
||||
"author": "Silverhand Inc.",
|
||||
"license": "MPL-2.0",
|
||||
"files": [
|
||||
"lib",
|
||||
"jest.config.ts"
|
||||
],
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"preinstall": "npx only-allow pnpm",
|
||||
"precommit": "lint-staged",
|
||||
"build": "rm -rf lib/ && tsc",
|
||||
"lint": "eslint --ext .ts jest.config.ts",
|
||||
"lint:report": "pnpm lint -- --format json --output-file report.json",
|
||||
"prepack": "pnpm build"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@silverhand/eslint-config": "^0.10.2",
|
||||
"@silverhand/ts-config": "^0.10.2",
|
||||
"@types/node": "16",
|
||||
"eslint": "^8.10.0",
|
||||
"jest": "^27.5.1",
|
||||
"lint-staged": "^12.0.0",
|
||||
"prettier": "^2.3.2",
|
||||
"ts-node": "^10.0.0",
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "@silverhand"
|
||||
},
|
||||
"prettier": "@silverhand/eslint-config/.prettierrc",
|
||||
"dependencies": {
|
||||
"@jest/types": "^27.5.1",
|
||||
"deepmerge": "^4.2.2",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"jest-matcher-specific-error": "^1.0.0",
|
||||
"jest-transform-stub": "^2.0.0",
|
||||
"ts-jest": "^27.1.1"
|
||||
}
|
||||
}
|
10
packages/jest-config/tsconfig.json
Normal file
10
packages/jest-config/tsconfig.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"extends": "@silverhand/ts-config/tsconfig.base",
|
||||
"compilerOptions": {
|
||||
"outDir": "lib",
|
||||
"declaration": true
|
||||
},
|
||||
"include": [
|
||||
"jest.config.ts"
|
||||
]
|
||||
}
|
|
@ -1,30 +1,8 @@
|
|||
import type { Config } from '@jest/types';
|
||||
import { merge, Config } from '@logto/jest-config';
|
||||
|
||||
const config: Config.InitialOptions = {
|
||||
preset: 'ts-jest',
|
||||
const config: Config.InitialOptions = merge({
|
||||
testEnvironment: 'jsdom',
|
||||
transform: {
|
||||
// Enable JS/JSX transformation
|
||||
'\\.(ts|js)x?$': 'ts-jest',
|
||||
'\\.(svg)$': 'jest-transform-stub',
|
||||
},
|
||||
transformIgnorePatterns: [
|
||||
'[/\\\\]node_modules[/\\\\]((?!ky[/\\\\]).)+\\.(js|jsx|mjs|cjs|ts|tsx)$',
|
||||
],
|
||||
moduleNameMapper: {
|
||||
// Map path alias in `tsconfig.json`
|
||||
'@/(.*)': '<rootDir>/src/$1',
|
||||
// Mock CSS Modules
|
||||
'\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
|
||||
},
|
||||
setupFilesAfterEnv: ['<rootDir>/src/jest.setup.ts'],
|
||||
coveragePathIgnorePatterns: ['/node_modules/', '/dist/', '/src/__mocks__/'],
|
||||
coverageReporters: ['text-summary', 'lcov'],
|
||||
globals: {
|
||||
'ts-jest': {
|
||||
tsconfig: './tsconfig.test.json',
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
export default config;
|
||||
|
|
|
@ -16,15 +16,36 @@
|
|||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@logto/jest-config": "^0.1.0",
|
||||
"@logto/phrases": "^0.1.0",
|
||||
"@logto/schemas": "^0.1.0",
|
||||
"@parcel/core": "^2.3.2",
|
||||
"@parcel/transformer-sass": "^2.3.2",
|
||||
"@peculiar/webcrypto": "^1.3.3",
|
||||
"@silverhand/eslint-config": "^0.10.2",
|
||||
"@silverhand/eslint-config-react": "^0.10.3",
|
||||
"@silverhand/essentials": "^1.1.7",
|
||||
"@silverhand/ts-config": "^0.10.2",
|
||||
"@silverhand/ts-config-react": "^0.10.3",
|
||||
"@testing-library/react": "^12.0.0",
|
||||
"@types/jest": "^27.4.1",
|
||||
"@types/react": "^17.0.14",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"@types/react-modal": "^3.13.1",
|
||||
"@types/react-router-dom": "^5.3.2",
|
||||
"classnames": "^2.3.1",
|
||||
"eslint": "^8.10.0",
|
||||
"i18next": "^21.6.11",
|
||||
"i18next-browser-languagedetector": "^6.1.3",
|
||||
"jest": "^27.5.1",
|
||||
"js-base64": "^3.7.2",
|
||||
"ky": "^0.30.0",
|
||||
"libphonenumber-js": "^1.9.49",
|
||||
"lint-staged": "^12.0.0",
|
||||
"parcel": "^2.3.2",
|
||||
"postcss": "^8.4.6",
|
||||
"postcss-modules": "^4.3.0",
|
||||
"prettier": "^2.3.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-i18next": "^11.15.4",
|
||||
|
@ -33,31 +54,7 @@
|
|||
"react-router-dom": "^6.2.2",
|
||||
"react-string-replace": "^1.0.0",
|
||||
"react-timer-hook": "^3.0.5",
|
||||
"@jest/types": "^27.5.1",
|
||||
"@parcel/core": "^2.3.2",
|
||||
"@parcel/transformer-sass": "^2.3.2",
|
||||
"@peculiar/webcrypto": "^1.3.3",
|
||||
"@silverhand/eslint-config": "^0.10.2",
|
||||
"@silverhand/eslint-config-react": "^0.10.3",
|
||||
"@silverhand/ts-config": "^0.10.2",
|
||||
"@silverhand/ts-config-react": "^0.10.3",
|
||||
"@testing-library/react": "^13.0.0",
|
||||
"@types/jest": "^27.4.0",
|
||||
"@types/react": "^17.0.14",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"@types/react-modal": "^3.13.1",
|
||||
"@types/react-router-dom": "^5.3.2",
|
||||
"eslint": "^8.10.0",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"jest": "^27.5.1",
|
||||
"jest-transform-stub": "^2.0.0",
|
||||
"lint-staged": "^12.0.0",
|
||||
"parcel": "^2.3.2",
|
||||
"postcss": "^8.4.6",
|
||||
"postcss-modules": "^4.3.0",
|
||||
"prettier": "^2.3.2",
|
||||
"stylelint": "^13.13.1",
|
||||
"ts-jest": "^27.1.1",
|
||||
"typescript": "^4.6.2"
|
||||
},
|
||||
"alias": {
|
||||
|
|
556
pnpm-lock.yaml
generated
556
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue