test: global test

pull/13/head
moonrailgun 4 years ago
parent ea940bdb27
commit e73139a476

@ -1,19 +1,21 @@
const { compilerOptions } = require('./tsconfig');
const regeneratorRuntime = require('regenerator-runtime'); const regeneratorRuntime = require('regenerator-runtime');
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = { module.exports = {
preset: 'ts-jest', preset: 'ts-jest',
testEnvironment: 'jsdom', testEnvironment: 'jsdom',
moduleNameMapper: { moduleNameMapper: {
'\\.(css|less|scss)$': 'identity-obj-proxy', '\\.(css|less|scss)$': 'identity-obj-proxy',
}, },
// projects: ['<rootDir>', '<rootDir>/web/*'], // https://jestjs.io/docs/next/configuration#projects-arraystring--projectconfig // projects: ['<rootDir>/web/'], // https://jestjs.io/docs/configuration#projects-arraystring--projectconfig
rootDir: '.', rootDir: '.',
testRegex: '.*\\.(test|spec)\\.tsx?$', testRegex: '.*\\.(test|spec)\\.tsx?$',
testPathIgnorePatterns: ['/node_modules/'], testPathIgnorePatterns: ['/node_modules/'],
transform: { transform: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/test/fileTransformer.js', '<rootDir>/test/fileTransformer.js',
'^.+\\.jsx?$': 'babel-jest', //这个是jest的默认配置
'^.+\\.ts?$': 'ts-jest' //typescript转换
}, },
transformIgnorePatterns: ['/node_modules/'], transformIgnorePatterns: ['/node_modules/'],
setupFilesAfterEnv: [], setupFilesAfterEnv: [],

@ -10,5 +10,13 @@
"repository": "https://github.com/pawchat/pawchat.git", "repository": "https://github.com/pawchat/pawchat.git",
"author": "moonrailgun <moonrailgun@gmail.com>", "author": "moonrailgun <moonrailgun@gmail.com>",
"license": "GPLv3", "license": "GPLv3",
"private": true "private": true,
"scripts": {
"test": "jest"
},
"devDependencies": {
"@types/jest": "^26.0.23",
"jest": "^27.0.6",
"ts-jest": "^27.0.3"
}
} }

@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "esnext",
"lib": ["DOM"],
"jsx": "react",
"esModuleInterop": true,
"isolatedModules": true,
"module": "ESNext",
"moduleResolution": "node",
"typeRoots": ["./node_modules/@types", "../node_modules/@types", "./types"]
}
}

@ -8,8 +8,7 @@
"private": true, "private": true,
"scripts": { "scripts": {
"build": "cross-env TS_NODE_PROJECT='tsconfig.node.json' webpack", "build": "cross-env TS_NODE_PROJECT='tsconfig.node.json' webpack",
"dev": "cross-env TS_NODE_PROJECT='tsconfig.node.json' NODE_ENV=development webpack serve", "dev": "cross-env TS_NODE_PROJECT='tsconfig.node.json' NODE_ENV=development webpack serve"
"test": "jest"
}, },
"dependencies": { "dependencies": {
"@iconify/iconify": "^2.0.2", "@iconify/iconify": "^2.0.2",
@ -27,7 +26,6 @@
"tailwindcss": "^2.2.4" "tailwindcss": "^2.2.4"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.23",
"@types/mini-css-extract-plugin": "^1.4.3", "@types/mini-css-extract-plugin": "^1.4.3",
"@types/node": "^15.12.5", "@types/node": "^15.12.5",
"@types/react": "^17.0.11", "@types/react": "^17.0.11",
@ -42,14 +40,12 @@
"esbuild-loader": "^2.13.1", "esbuild-loader": "^2.13.1",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"html-webpack-plugin": "^5.3.2", "html-webpack-plugin": "^5.3.2",
"jest": "^27.0.6",
"less": "^4.1.1", "less": "^4.1.1",
"less-loader": "^10.0.0", "less-loader": "^10.0.0",
"mini-css-extract-plugin": "^1.6.2", "mini-css-extract-plugin": "^1.6.2",
"postcss": "^8.3.5", "postcss": "^8.3.5",
"postcss-loader": "^6.1.0", "postcss-loader": "^6.1.0",
"style-loader": "^3.0.0", "style-loader": "^3.0.0",
"ts-jest": "^27.0.3",
"ts-node": "^10.0.0", "ts-node": "^10.0.0",
"tsconfig-paths": "^3.9.0", "tsconfig-paths": "^3.9.0",
"typescript": "^4.3.4", "typescript": "^4.3.4",

@ -1,12 +1,3 @@
{ {
"compilerOptions": { "extends": "../tsconfig.json"
"target": "esnext",
"lib": ["DOM"],
"jsx": "react",
"esModuleInterop": true,
"isolatedModules": true,
"module": "ESNext",
"moduleResolution": "node",
"typeRoots": ["./node_modules/@types", "../node_modules/@types", "./types"]
}
} }

@ -4243,7 +4243,7 @@ jest-worker@^27.0.2, jest-worker@^27.0.6:
jest@^27.0.6: jest@^27.0.6:
version "27.0.6" version "27.0.6"
resolved "https://registry.npmjs.org/jest/-/jest-27.0.6.tgz#10517b2a628f0409087fbf473db44777d7a04505" resolved "https://registry.yarnpkg.com/jest/-/jest-27.0.6.tgz#10517b2a628f0409087fbf473db44777d7a04505"
integrity sha512-EjV8aETrsD0wHl7CKMibKwQNQc3gIRBXlTikBmmHUeVMKaPFxdcUIBfoDqTSXDoGJIivAYGqCWVlzCSaVjPQsA== integrity sha512-EjV8aETrsD0wHl7CKMibKwQNQc3gIRBXlTikBmmHUeVMKaPFxdcUIBfoDqTSXDoGJIivAYGqCWVlzCSaVjPQsA==
dependencies: dependencies:
"@jest/core" "^27.0.6" "@jest/core" "^27.0.6"

Loading…
Cancel
Save