Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/before-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { configure } from 'enzyme';
import * as Adapter from 'enzyme-adapter-react-16';

// http://airbnb.io/enzyme/docs/installation/index.html#working-with-react-16
configure({adapter: new Adapter()});
configure({ adapter: new Adapter() });

window.SERVER_FLAGS = {
basePath: '/',
Expand Down
45 changes: 45 additions & 0 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// https://jestjs.io/docs/en/configuration.html
// https://kulshekhar.github.io/ts-jest/user/config/

const { jsWithTs: tsJestPreset } = require('ts-jest/presets');

module.exports = {
moduleFileExtensions: [
'js', 'jsx', 'ts', 'tsx'
],
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',
'\\.(css|less)$': '<rootDir>/__mocks__/styleMock.js'
},
transform: {
...tsJestPreset.transform,
},
transformIgnorePatterns: [
'<rootDir>/node_modules/(?!lodash-es|@console)'
],
testRegex: '/__tests__/.*\\.(ts|tsx|js|jsx)$',
setupFiles: [
'./__mocks__/requestAnimationFrame.js',
'./__mocks__/localStorage.ts',
'./__mocks__/matchMedia.js',
],
setupFilesAfterEnv: [
'./before-tests.js',
],
snapshotResolver: './snapshotResolver.js',
globals: {
'ts-jest': {
isolatedModules: true,
},
},
coverageDirectory: '__coverage__',
coverageReporters: [
'json', 'lcov', 'text', 'text-summary'
],
collectCoverageFrom: [
'public/*.{js,jsx,ts,tsx}',
'public/{components,module,ui}/**/*.{js,jsx,ts,tsx}',
'packages/*/src/**/*.{js,jsx,ts,tsx}',
'!**/node_modules/**'
]
};
50 changes: 7 additions & 43 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,6 @@
"debug-test-suite": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' node -r ts-node/register --inspect-brk ./node_modules/.bin/protractor integration-tests/protractor.conf.ts",
"analyze": "NODE_ENV=production ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack --mode=production --profile --json | awk '{if(NR>2)print}' > public/dist/stats.json && ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack-bundle-analyzer --mode static -r public/dist/report.html public/dist/stats.json"
},
"jest": {
"moduleFileExtensions": [
"js",
"jsx",
"ts",
"tsx"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
},
"transform": {
".(ts|tsx|js|jsx)": "./node_modules/ts-jest/preprocessor.js"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!lodash-es|@console)"
],
"testRegex": "/__tests__/.*\\.(ts|tsx|js|jsx)$",
"setupFiles": [
"./__mocks__/requestAnimationFrame.js",
"./__mocks__/localStorage.ts",
"./__mocks__/matchMedia.js",
"./before-tests.js"
],
"coverageDirectory": "__coverage__",
"coverageReporters": [
"json",
"lcov",
"text",
"text-summary"
],
"collectCoverageFrom": [
"public/*.{js,jsx,ts,tsx}",
"public/{components,module,ui}/**/*.{js,jsx,ts,tsx}",
"packages/*/src/**/*.{js,jsx,ts,tsx}",
"!**/node_modules/**"
]
},
"dependencies": {
"@patternfly/patternfly": "2.8.2",
"@patternfly/react-charts": "3.4.5",
Expand Down Expand Up @@ -117,6 +79,7 @@
"@types/immutable": "3.x",
"@types/jasmine": "2.8.x",
"@types/jasminewd2": "2.0.x",
"@types/jest": "24.x",
"@types/lodash-es": "4.x",
"@types/prop-types": "15.5.6",
"@types/react": "16.8.13",
Expand All @@ -136,8 +99,9 @@
"chromedriver": "^2.43.3",
"circular-dependency-plugin": "5.0.2",
"css-loader": "0.28.x",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "1.12.1",
"enzyme": "3.x",
"enzyme-adapter-react-16": "1.13.2",
"enzyme-to-json": "3.x",
"eslint": "5.16.0",
"eslint-plugin-import": "2.x",
"eslint-plugin-react": "7.x",
Expand All @@ -150,8 +114,8 @@
"jasmine-console-reporter": "2.x",
"jasmine-core": "2.x",
"jasmine-reporters": "2.x",
"jest": "21.x",
"jest-cli": "21.x",
"jest": "24.x",
"jest-cli": "24.x",
"mini-css-extract-plugin": "0.4.x",
"node-sass": "4.8.x",
"protractor": "5.4.x",
Expand All @@ -161,7 +125,7 @@
"resolve-url-loader": "2.x",
"sass-loader": "6.x",
"thread-loader": "1.x",
"ts-jest": "21.x",
"ts-jest": "24.x",
"ts-loader": "5.3.3",
"ts-node": "5.x",
"typescript": "3.4.4",
Expand Down
14 changes: 14 additions & 0 deletions frontend/snapshotResolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// https://jestjs.io/docs/en/configuration.html#snapshotresolver-string

module.exports = {
// example test path, used for preflight consistency check
testPathForConsistencyCheck: 'some/__tests__/example.spec.ts',

// map test path to snapshot path
resolveSnapshotPath: (testPath, snapshotExtension) =>
testPath.replace(/\.spec\.([tj]sx?)/, `${snapshotExtension}.$1`),

// map snapshot path to test path
resolveTestPath: (snapshotFilePath, snapshotExtension) =>
snapshotFilePath.replace(snapshotExtension, '.spec'),
};
6 changes: 5 additions & 1 deletion frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
"downlevelIteration": true,
"experimentalDecorators": true,
"sourceMap": true,
"noUnusedLocals": true
"noUnusedLocals": true,
"types": [
"jest",
"jasmine"
]
},
"exclude": [
".yarn",
Expand Down
Loading