test: wip: tspath for jest

release/desktop
moonrailgun 3 years ago
parent 4c9f5ec5f2
commit 082a6bf611

@ -14,7 +14,7 @@
"prepare": "husky install",
"translation": "node build/script/scanTranslation.js",
"lint:fix": "eslint --fix './**/*.{ts,tsx}'",
"test": "jest"
"test": "cd web && yarn test"
},
"lint-staged": {
"src/*.{json,less}": [
@ -31,7 +31,6 @@
"devDependencies": {
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@types/jest": "^26.0.23",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"commitlint": "^12.1.4",
@ -45,10 +44,8 @@
"husky": "^7.0.0",
"i18next-scanner": "^3.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.0.6",
"lint-staged": "^11.0.0",
"prettier": "^2.3.2",
"ts-jest": "^27.0.3",
"vinyl-fs": "^3.0.3"
}
}

@ -1,4 +1,6 @@
const regeneratorRuntime = require('regenerator-runtime');
const { pathsToModuleNameMapper } = require('ts-jest');
const webCompilerOptions = require('./tsconfig.json').compilerOptions;
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
@ -6,9 +8,12 @@ module.exports = {
testEnvironment: 'jsdom',
moduleNameMapper: {
'\\.(css|less|scss)$': 'identity-obj-proxy',
...pathsToModuleNameMapper(webCompilerOptions.paths, {
prefix: '<rootDir>/web/',
}),
},
// projects: ['<rootDir>/web/'], // https://jestjs.io/docs/configuration#projects-arraystring--projectconfig
rootDir: '.',
rootDir: '../',
testRegex: '.*\\.(test|spec)\\.tsx?$',
testPathIgnorePatterns: ['/node_modules/', '/e2e/cypress/'],
transform: {

@ -10,6 +10,7 @@
"build": "yarn plugins:all && cross-env TS_NODE_PROJECT='tsconfig.node.json' webpack --config ./build/webpack.config.ts",
"dev": "cross-env TS_NODE_PROJECT='tsconfig.node.json' NODE_ENV=development webpack serve --config ./build/webpack.config.ts",
"serve": "npx http-server ./dist",
"test": "jest",
"analysis": "cross-env ANALYSIS=true yarn build",
"check:type": "tsc --noEmit --skipLibCheck",
"postinstall": "yarn plugins:install",
@ -57,6 +58,7 @@
"@types/dts-generator": "^2.1.6",
"@types/emoji-mart": "^3.0.8",
"@types/is-hotkey": "^0.1.5",
"@types/jest": "^27.0.3",
"@types/loadable__component": "^5.13.4",
"@types/mini-css-extract-plugin": "^1.4.3",
"@types/node": "^15.12.5",
@ -82,6 +84,7 @@
"execa": "^5.1.1",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.3.2",
"jest": "^27.4.5",
"less": "^4.1.1",
"less-loader": "^10.0.0",
"mini-css-extract-plugin": "^1.6.2",
@ -89,6 +92,7 @@
"postcss-loader": "^6.1.0",
"rollup-plugin-copy": "^3.4.0",
"style-loader": "^3.0.0",
"ts-jest": "^27.1.2",
"ts-node": "^10.0.0",
"tsconfig-paths": "^3.9.0",
"tsconfig-paths-webpack-plugin": "^3.5.1",

@ -0,0 +1,12 @@
import { buildDataFromValues } from '../helper';
describe('buildDataFromValues', () => {
test.each([
[
{ name: 'name', type: 'type' },
{ name: 'name', type: 'type' },
],
])('%o', (input, output) => {
expect(buildDataFromValues(input)).toEqual(output);
});
});

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save