-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate to jest fix jhipster/generator-jhipster#15171
- Loading branch information
Showing
22 changed files
with
5,974 additions
and
4,237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
node_modules/ | ||
tests/karma.conf.js | ||
webpack.config.js | ||
target/ | ||
build/ | ||
bundles/ | ||
lib/ | ||
coverage/ | ||
node_modules/ | ||
jest.conf.js | ||
node/ | ||
postcss.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,79 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"extends": [ | ||
"jhipster-react" | ||
"plugin:react/recommended", | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"prettier", | ||
"eslint-config-prettier" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": 2018, | ||
"sourceType": "module", | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"project": "./tsconfig.json" | ||
}, | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
} | ||
}, | ||
"rules": { | ||
"@typescript-eslint/explicit-module-boundary-types": [ | ||
"warn" | ||
], | ||
"@typescript-eslint/no-unsafe-assignment": [ | ||
"warn" | ||
], | ||
"@typescript-eslint/no-unsafe-call": [ | ||
"warn" | ||
], | ||
"@typescript-eslint/no-unsafe-member-access": [ | ||
"warn" | ||
], | ||
"@typescript-eslint/no-unsafe-return": [ | ||
"warn" | ||
], | ||
"no-shadow": [ | ||
"warn" | ||
], | ||
"@typescript-eslint/restrict-template-expressions": [ | ||
"warn" | ||
], | ||
"@typescript-eslint/restrict-plus-operands": [ | ||
"warn" | ||
"@typescript-eslint/member-ordering": [ | ||
"error", | ||
{ | ||
"default": ["static-field", "instance-field", "constructor", "static-method", "instance-method"] | ||
} | ||
], | ||
"@typescript-eslint/no-parameter-properties": ["warn", { "allows": ["public", "private", "protected"] }], | ||
"@typescript-eslint/no-unused-vars": "off", | ||
"@typescript-eslint/explicit-member-accessibility": "off", | ||
"@typescript-eslint/explicit-function-return-type": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-unsafe-return": "off", | ||
"@typescript-eslint/no-unsafe-member-access": "off", | ||
"@typescript-eslint/no-unsafe-call": "off", | ||
"@typescript-eslint/no-unsafe-assignment": "off", | ||
"@typescript-eslint/explicit-module-boundary-types": "off", | ||
"@typescript-eslint/restrict-template-expressions": "off", | ||
"@typescript-eslint/restrict-plus-operands": "off", | ||
"@typescript-eslint/no-floating-promises": "off", | ||
"@typescript-eslint/ban-types": [ | ||
"warn" | ||
] | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["./tests/spec/**/*"], | ||
"rules": { | ||
"@typescript-eslint/no-unsafe-return": "off", | ||
"@typescript-eslint/no-unsafe-assignment": "off", | ||
"@typescript-eslint/no-unsafe-call": "off", | ||
"@typescript-eslint/no-unsafe-member-access": "off" | ||
"error", | ||
{ | ||
"types": { | ||
"Object": "Use {} instead." | ||
} | ||
} | ||
} | ||
] | ||
], | ||
"@typescript-eslint/interface-name-prefix": "off", | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/unbound-method": "off", | ||
"@typescript-eslint/array-type": "off", | ||
"@typescript-eslint/no-shadow": "error", | ||
"spaced-comment": ["warn", "always"], | ||
"guard-for-in": "error", | ||
"no-labels": "error", | ||
"no-caller": "error", | ||
"no-bitwise": "error", | ||
"no-console": ["error", { "allow": ["warn", "error"] }], | ||
"no-new-wrappers": "error", | ||
"no-eval": "error", | ||
"no-new": "error", | ||
"no-var": "error", | ||
"radix": "error", | ||
"eqeqeq": ["error", "always", { "null": "ignore" }], | ||
"prefer-const": "error", | ||
"object-shorthand": ["error", "always", { "avoidExplicitReturnArrows": true }], | ||
"default-case": "error", | ||
"complexity": ["error", 40], | ||
"no-invalid-this": "off", | ||
"react/prop-types": "off", | ||
"react/display-name": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ coverage | |
*.metadata.json | ||
/bundles | ||
/lib/tests | ||
build/ | ||
|
||
################# | ||
## IDE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const tsconfig = require('./tsconfig.json'); | ||
|
||
module.exports = { | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest', | ||
}, | ||
testURL: 'http://localhost/', | ||
cacheDirectory: '<rootDir>/build/jest-cache', | ||
coverageDirectory: '<rootDir>/build/test-results/', | ||
testMatch: ['<rootDir>/src/**/@(*.)@(spec.ts?(x))'], | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
moduleNameMapper: mapTypescriptAliasToJestAlias({ | ||
'\\.(css|scss)$': 'identity-obj-proxy', | ||
}), | ||
reporters: ['default', ['jest-junit', { outputDirectory: './build/test-results/', outputName: 'TESTS-results-jest.xml' }]], | ||
testPathIgnorePatterns: ['<rootDir>/node_modules/'], | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: './tsconfig.test.json', | ||
compiler: 'typescript', | ||
diagnostics: false, | ||
}, | ||
}, | ||
}; | ||
|
||
function mapTypescriptAliasToJestAlias(alias = {}) { | ||
const jestAliases = { ...alias }; | ||
if (!tsconfig.compilerOptions.paths) { | ||
return jestAliases; | ||
} | ||
Object.entries(tsconfig.compilerOptions.paths) | ||
.filter(([key, value]) => { | ||
// use Typescript alias in Jest only if this has value | ||
if (value.length) { | ||
return true; | ||
} | ||
return false; | ||
}) | ||
.map(([key, value]) => { | ||
// if Typescript alias ends with /* then in Jest: | ||
// - alias key must end with /(.*) | ||
// - alias value must end with /$1 | ||
const regexToReplace = /(.*)\/\*$/; | ||
const aliasKey = key.replace(regexToReplace, '$1/(.*)'); | ||
const aliasValue = value[0].replace(regexToReplace, '$1/$$1'); | ||
return [aliasKey, `<rootDir>/${aliasValue}`]; | ||
}) | ||
.reduce((aliases, [key, value]) => { | ||
aliases[key] = value; | ||
return aliases; | ||
}, jestAliases); | ||
return jestAliases; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.