0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

test(toolkit): use native ESM

This commit is contained in:
Gao Sun 2022-12-15 01:50:29 +08:00
parent 4cc7664148
commit 49682afdb5
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
17 changed files with 57 additions and 80 deletions

View file

@ -7,7 +7,7 @@ module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', [...rules['type-enum'][2], 'api', 'release']],
'scope-enum': [2, 'always', ['connector', 'console', 'core', 'demo-app', 'test', 'phrases', 'schemas', 'shared', 'ui', 'deps', 'connector-core', 'cli']],
'scope-enum': [2, 'always', ['connector', 'console', 'core', 'demo-app', 'test', 'phrases', 'schemas', 'shared', 'ui', 'deps','cli', 'toolkit']],
// Slightly increase the tolerance to allow the appending PR number
...(isCi && { 'header-max-length': [2, 'always', 110] })
},

View file

@ -33,7 +33,7 @@
"lint:report": "pnpm lint --format json --output-file report.json",
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build:test && pnpm test:only",
"test:ci": "pnpm run test:only",
"test:ci": "pnpm test:only",
"prepack": "pnpm build"
},
"engines": {

View file

@ -21,7 +21,7 @@
"start": "NODE_ENV=production node build/index.js",
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build:test && pnpm test:only",
"test:ci": "pnpm run test:only --coverage --silent",
"test:ci": "pnpm test:only --coverage --silent",
"test:report": "codecov -F core"
},
"dependencies": {

View file

@ -27,7 +27,7 @@
"prepack": "pnpm build",
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build:test && pnpm test:only",
"test:ci": "pnpm run test:only"
"test:ci": "pnpm test:only"
},
"engines": {
"node": "^16.13.0 || ^18.12.0"

View file

@ -29,7 +29,7 @@
"prepack": "pnpm build",
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build:test && pnpm test:only",
"test:ci": "pnpm run test:only"
"test:ci": "pnpm test:only"
},
"devDependencies": {
"@silverhand/eslint-config": "1.3.0",

View file

@ -22,8 +22,8 @@
"scripts": {
"precommit": "lint-staged",
"dev": "tsc --watch --preserveWatchOutput --incremental",
"build:test": "pnpm build",
"build": "rm -rf lib/ && rollup -c && tsc",
"build:test": "pnpm build",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
"prepack": "pnpm build"

View file

@ -0,0 +1,12 @@
/** @type {import('jest').Config} */
const config = {
coveragePathIgnorePatterns: ['/node_modules/', '/src/__mocks__/'],
coverageReporters: ['text-summary', 'lcov'],
setupFilesAfterEnv: ['jest-matcher-specific-error'],
roots: ['./lib'],
moduleNameMapper: {
'^(chalk|inquirer)$': '<rootDir>/../../shared/lib/esm/module-proxy.js',
},
};
export default config;

View file

@ -1,13 +0,0 @@
import type { Config } from '@jest/types';
const config: Config.InitialOptions = {
preset: 'ts-jest',
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
collectCoverageFrom: ['src/**/*.ts'],
coverageReporters: ['lcov', 'text-summary'],
setupFilesAfterEnv: ['jest-matcher-specific-error'],
};
export default config;

View file

@ -25,13 +25,15 @@
"precommit": "lint-staged",
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental",
"build": "rm -rf lib/ && rollup -c && tsc -p tsconfig.build.json",
"build:test": "pnpm build",
"build:test": "pnpm build -p tsconfig.test.json --sourcemap",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
"prepack": "pnpm build",
"stylelint": "stylelint \"scss/**/*.scss\"",
"test": "jest",
"test:coverage": "jest --silent --coverage"
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build:test && pnpm test:only",
"test:ci": "pnpm test:only",
"test:coverage": "pnpm test:only --silent --coverage"
},
"engines": {
"node": "^16.13.0 || ^18.12.0"
@ -63,7 +65,6 @@
"prettier": "^2.7.1",
"rollup": "^3.6.0",
"stylelint": "^14.9.1",
"ts-jest": "^29.0.1",
"tslib": "^2.4.1",
"typescript": "^4.9.4"
},

View file

@ -6,5 +6,5 @@
"moduleResolution": "nodenext",
"module": "esnext"
},
"include": ["src", "declaration", "jest.config.ts"]
"include": ["src", "declaration"]
}

View file

@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"isolatedModules": false,
"allowJs": true
},
"include": ["src"]
}

View file

@ -0,0 +1,11 @@
/** @type {import('jest').Config} */
const config = {
coveragePathIgnorePatterns: ['/node_modules/', '/src/__mocks__/'],
coverageReporters: ['text-summary', 'lcov'],
roots: ['./lib'],
moduleNameMapper: {
'^(chalk|inquirer)$': '<rootDir>/../../shared/lib/esm/module-proxy.js',
},
};
export default config;

View file

@ -1,12 +0,0 @@
import type { Config } from '@jest/types';
const config: Config.InitialOptions = {
preset: 'ts-jest',
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
collectCoverageFrom: ['src/**/*.ts'],
coverageReporters: ['lcov', 'text-summary'],
};
export default config;

View file

@ -22,12 +22,14 @@
"scripts": {
"precommit": "lint-staged",
"build": "rm -rf lib/ && rollup -c && tsc -p tsconfig.build.json",
"build:test": "pnpm build",
"build:test": "pnpm build -p tsconfig.test.json --sourcemap",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
"prepack": "pnpm build",
"test": "jest",
"test:coverage": "jest --silent --coverage"
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build:test && pnpm test:only",
"test:ci": "pnpm test:only",
"test:coverage": "pnpm test:only --silent --coverage"
},
"engines": {
"node": "^16.13.0 || ^18.12.0"
@ -47,7 +49,6 @@
"lint-staged": "^13.0.0",
"prettier": "^2.7.1",
"rollup": "^3.6.0",
"ts-jest": "^29.0.1",
"tslib": "^2.4.1",
"typescript": "^4.9.4"
},

View file

@ -5,6 +5,5 @@
"baseUrl": ".",
"moduleResolution": "nodenext",
"module": "esnext"
},
"include": ["src", "jest.config.ts"]
}
}

View file

@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"isolatedModules": false,
"allowJs": true
},
"include": ["src"]
}

View file

@ -704,7 +704,6 @@ importers:
prettier: ^2.7.1
rollup: ^3.6.0
stylelint: ^14.9.1
ts-jest: ^29.0.1
tslib: ^2.4.1
typescript: ^4.9.4
zod: ^3.20.2
@ -733,7 +732,6 @@ importers:
prettier: 2.7.1
rollup: 3.7.4
stylelint: 14.9.1
ts-jest: 29.0.3_a67wnu7kur6t3xg6vztzc6sc5i
tslib: 2.4.1
typescript: 4.9.4
@ -750,7 +748,6 @@ importers:
lint-staged: ^13.0.0
prettier: ^2.7.1
rollup: ^3.6.0
ts-jest: ^29.0.1
tslib: ^2.4.1
typescript: ^4.9.4
zod: ^3.20.2
@ -768,7 +765,6 @@ importers:
lint-staged: 13.0.0
prettier: 2.7.1
rollup: 3.7.4
ts-jest: 29.0.3_a67wnu7kur6t3xg6vztzc6sc5i
tslib: 2.4.1
typescript: 4.9.4
@ -14429,40 +14425,6 @@ packages:
resolution: {integrity: sha512-AqTiAOLcj85xS7vQ8QkAV41hPDIJ71XJB4RCUrzo/1GM2CQwhkJGaf9Hgr7BOugMRpgGUrqRg/DrBDl4H40+8g==}
dev: true
/ts-jest/29.0.3_a67wnu7kur6t3xg6vztzc6sc5i:
resolution: {integrity: sha512-Ibygvmuyq1qp/z3yTh9QTwVVAbFdDy/+4BtIQR2sp6baF2SJU/8CKK/hhnGIDY2L90Az2jIqTwZPnN2p+BweiQ==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
hasBin: true
peerDependencies:
'@babel/core': '>=7.0.0-beta.0 <8'
'@jest/types': ^29.0.0
babel-jest: ^29.0.0
esbuild: '*'
jest: ^29.0.0 || ^29.1.2
typescript: '>=4.3'
peerDependenciesMeta:
'@babel/core':
optional: true
'@jest/types':
optional: true
babel-jest:
optional: true
esbuild:
optional: true
dependencies:
'@jest/types': 29.3.1
bs-logger: 0.2.6
fast-json-stable-stringify: 2.1.0
jest: 29.3.1_@types+node@16.11.12
jest-util: 29.3.1
json5: 2.2.1
lodash.memoize: 4.1.2
make-error: 1.3.6
semver: 7.3.8
typescript: 4.9.4
yargs-parser: 21.1.1
dev: true
/ts-jest/29.0.3_h5yo4o4jl7fzim4gycvvdmdsqu:
resolution: {integrity: sha512-Ibygvmuyq1qp/z3yTh9QTwVVAbFdDy/+4BtIQR2sp6baF2SJU/8CKK/hhnGIDY2L90Az2jIqTwZPnN2p+BweiQ==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}