0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor: remove jest

This commit is contained in:
Gao Sun 2024-03-28 12:07:54 +08:00
parent afda22efa2
commit 412a3df1cf
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
16 changed files with 29 additions and 149 deletions

View file

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

View file

@ -26,14 +26,11 @@
"precommit": "lint-staged",
"dev": "tsc --watch --preserveWatchOutput --incremental",
"build": "rm -rf lib/ && tsc",
"build:test": "pnpm build",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
"prepack": "pnpm build",
"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"
"test": "vitest src",
"test:ci": "pnpm run test --silent --coverage"
},
"dependencies": {
"@logto/language-kit": "workspace:^1.1.0",
@ -45,17 +42,14 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@jest/types": "^29.0.3",
"@silverhand/eslint-config": "5.0.0",
"@silverhand/ts-config": "5.0.0",
"@types/jest": "^29.4.0",
"@types/node": "^20.9.5",
"eslint": "^8.44.0",
"jest": "^29.7.0",
"lint-staged": "^15.0.0",
"prettier": "^3.0.0",
"tslib": "^2.4.1",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"vitest": "^1.4.0"
},
"engines": {
"node": "^20.9.0"

View file

@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { z } from 'zod';
import {

View file

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

View file

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

View file

@ -1,4 +0,0 @@
import crypto from 'node:crypto';
// eslint-disable-next-line @silverhand/fp/no-mutation
global.crypto = crypto;

View file

@ -29,15 +29,12 @@
"precommit": "lint-staged",
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental",
"build": "rm -rf lib/ && tsc -p tsconfig.build.json",
"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: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"
"test": "vitest src",
"test:ci": "pnpm run test --silent --coverage"
},
"engines": {
"node": "^20.9.0"
@ -52,22 +49,19 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@jest/types": "^29.0.3",
"@silverhand/eslint-config": "5.0.0",
"@silverhand/ts-config": "5.0.0",
"@silverhand/ts-config-react": "5.0.0",
"@types/color": "^3.0.3",
"@types/jest": "^29.4.0",
"@types/node": "^20.9.5",
"@types/react": "^18.0.31",
"eslint": "^8.44.0",
"jest": "^29.7.0",
"lint-staged": "^15.0.0",
"postcss": "^8.4.31",
"prettier": "^3.0.0",
"stylelint": "^15.0.0",
"tslib": "^2.4.1",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"vitest": "^1.4.0"
},
"eslintConfig": {
"extends": "@silverhand"

View file

@ -1,14 +1,13 @@
import { describe, expect, it, beforeAll, afterAll, vi } from 'vitest';
import { ZodError } from 'zod';
import { PasswordPolicyChecker } from './password-policy.js';
const { jest } = import.meta;
const mockPwnResponse = () => {
const originalFetch = global.fetch;
beforeAll(() => {
// eslint-disable-next-line @silverhand/fp/no-mutation
global.fetch = jest.fn().mockResolvedValue({
global.fetch = vi.fn().mockResolvedValue({
// Return hash suffixes for '123456'.
text: async () =>
'D032E84B0AEB4E773555C73D6B13BEA7A44:1\nD09CA3762AF61E59520943DC26494F8941B:37615252',

View file

@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';
import { domainRegEx } from './regex.js';
describe('Regular expressions should work as expected', () => {

View file

@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';
import { isLocalhost, isValidUrl, validateRedirectUrl } from './url.js';
describe('url utilities', () => {

View file

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

View file

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

View file

@ -22,14 +22,11 @@
"scripts": {
"precommit": "lint-staged",
"build": "rm -rf lib/ && tsc -p tsconfig.build.json",
"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: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"
"test": "vitest src",
"test:ci": "pnpm run test --silent --coverage"
},
"engines": {
"node": "^20.9.0"
@ -38,17 +35,14 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@jest/types": "^29.0.3",
"@silverhand/eslint-config": "5.0.0",
"@silverhand/ts-config": "5.0.0",
"@types/jest": "^29.4.0",
"@types/node": "^20.9.5",
"eslint": "^8.44.0",
"jest": "^29.7.0",
"lint-staged": "^15.0.0",
"prettier": "^3.0.0",
"tslib": "^2.4.1",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"vitest": "^1.4.0"
},
"eslintConfig": {
"extends": "@silverhand"

View file

@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import { number, ZodError } from 'zod';
import { fallback, isLanguageTag, languageTagGuard } from './utility.js';

View file

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

View file

@ -3919,39 +3919,30 @@ importers:
specifier: ^3.22.4
version: 3.22.4
devDependencies:
'@jest/types':
specifier: ^29.0.3
version: 29.1.2
'@silverhand/eslint-config':
specifier: 5.0.0
version: 5.0.0(eslint@8.44.0)(prettier@3.0.0)(typescript@5.3.3)
'@silverhand/ts-config':
specifier: 5.0.0
version: 5.0.0(typescript@5.3.3)
'@types/jest':
specifier: ^29.4.0
version: 29.4.0
'@types/node':
specifier: ^20.9.5
version: 20.10.4
eslint:
specifier: ^8.44.0
version: 8.44.0
jest:
specifier: ^29.7.0
version: 29.7.0(@types/node@20.10.4)
lint-staged:
specifier: ^15.0.0
version: 15.0.2
prettier:
specifier: ^3.0.0
version: 3.0.0
tslib:
specifier: ^2.4.1
version: 2.4.1
typescript:
specifier: ^5.3.3
version: 5.3.3
vitest:
specifier: ^1.4.0
version: 1.4.0(@types/node@20.10.4)
packages/toolkit/core-kit:
dependencies:
@ -3972,9 +3963,6 @@ importers:
specifier: ^3.22.4
version: 3.22.4
devDependencies:
'@jest/types':
specifier: ^29.0.3
version: 29.3.1
'@silverhand/eslint-config':
specifier: 5.0.0
version: 5.0.0(eslint@8.44.0)(prettier@3.0.0)(typescript@5.3.3)
@ -3987,9 +3975,6 @@ importers:
'@types/color':
specifier: ^3.0.3
version: 3.0.3
'@types/jest':
specifier: ^29.4.0
version: 29.4.0
'@types/node':
specifier: ^20.9.5
version: 20.10.4
@ -3999,9 +3984,6 @@ importers:
eslint:
specifier: ^8.44.0
version: 8.44.0
jest:
specifier: ^29.7.0
version: 29.7.0(@types/node@20.10.4)
lint-staged:
specifier: ^15.0.0
version: 15.0.2
@ -4014,12 +3996,12 @@ importers:
stylelint:
specifier: ^15.0.0
version: 15.0.0
tslib:
specifier: ^2.4.1
version: 2.4.1
typescript:
specifier: ^5.3.3
version: 5.3.3
vitest:
specifier: ^1.4.0
version: 1.4.0(@types/node@20.10.4)
packages/toolkit/language-kit:
optionalDependencies:
@ -4027,39 +4009,30 @@ importers:
specifier: ^3.22.4
version: 3.22.4
devDependencies:
'@jest/types':
specifier: ^29.0.3
version: 29.3.1
'@silverhand/eslint-config':
specifier: 5.0.0
version: 5.0.0(eslint@8.44.0)(prettier@3.0.0)(typescript@5.3.3)
'@silverhand/ts-config':
specifier: 5.0.0
version: 5.0.0(typescript@5.3.3)
'@types/jest':
specifier: ^29.4.0
version: 29.4.0
'@types/node':
specifier: ^20.9.5
version: 20.10.4
eslint:
specifier: ^8.44.0
version: 8.44.0
jest:
specifier: ^29.7.0
version: 29.7.0(@types/node@20.10.4)
lint-staged:
specifier: ^15.0.0
version: 15.0.2
prettier:
specifier: ^3.0.0
version: 3.0.0
tslib:
specifier: ^2.4.1
version: 2.4.1
typescript:
specifier: ^5.3.3
version: 5.3.3
vitest:
specifier: ^1.4.0
version: 1.4.0(@types/node@20.10.4)
packages:
@ -7494,18 +7467,6 @@ packages:
chalk: 4.1.2
dev: true
/@jest/types@29.3.1:
resolution: {integrity: sha512-d0S0jmmTpjnhCmNpApgX3jrUZgZ22ivKJRvL2lli5hpCRoNnp1f85r2/wpKfXuYu8E7Jjh1hGfhPyup1NM5AmA==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dependencies:
'@jest/schemas': 29.0.0
'@types/istanbul-lib-coverage': 2.0.4
'@types/istanbul-reports': 3.0.1
'@types/node': 20.11.20
'@types/yargs': 17.0.13
chalk: 4.1.2
dev: true
/@jest/types@29.5.0:
resolution: {integrity: sha512-qbu7kN6czmVRc3xWFQcAN03RAUamgppVUdXrvl1Wr3jlNF93o9mJbGcDWrwGB6ht44u7efB1qCFgVQmca24Uog==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}