@corva/create-app 0.50.0-2 → 0.50.0-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/constants/package.js +41 -9
- package/package.json +1 -1
- package/templates/ui/javascript/config/jest/babelTransform.js +16 -0
- package/templates/ui/javascript/config/jest/cssTransform.js +16 -0
- package/templates/ui/javascript/config/jest/fileTransform.js +48 -0
- package/templates/ui/javascript/config/jest/globalSetup.js +5 -0
- package/templates/ui/javascript/config/jest/setupTests.js +11 -0
- package/templates/ui/javascript/gitignore +2 -0
- package/templates/ui/javascript/src/AppSettings.js +1 -0
- package/templates/ui/javascript/src/__mocks__/mockAppProps.js +580 -0
- package/templates/ui/javascript/src/__mocks__/mockAppSettingsProps.js +290 -0
- package/templates/ui/javascript/src/__tests__/App.test.js +21 -0
- package/templates/ui/javascript/src/__tests__/AppSettings.test.js +21 -0
- package/templates/ui/javascript/src/__tests__/TestsExample.test.js +37 -0
- package/templates/ui/typescript/config/jest/babelTransform.js +16 -0
- package/templates/ui/typescript/config/jest/cssTransform.js +16 -0
- package/templates/ui/typescript/config/jest/fileTransform.js +48 -0
- package/templates/ui/typescript/config/jest/globalSetup.js +5 -0
- package/templates/ui/typescript/config/jest/setupTests.js +11 -0
- package/templates/ui/typescript/gitignore +2 -0
- package/templates/ui/typescript/src/App.tsx +1 -1
- package/templates/ui/typescript/src/AppSettings.tsx +1 -0
- package/templates/ui/typescript/src/__mocks__/mockAppProps.ts +580 -0
- package/templates/ui/typescript/src/__mocks__/mockAppSettingsProps.ts +290 -0
- package/templates/ui/typescript/src/__tests__/App.test.tsx +21 -0
- package/templates/ui/typescript/src/__tests__/AppSettings.test.tsx +21 -0
- package/templates/ui/typescript/src/__tests__/TestsExample.test.tsx +37 -0
- package/templates/ui/javascript/src/__tests__/TestExample.test.js +0 -31
- package/templates/ui/javascript/src/setupTests.js +0 -2
- package/templates/ui/typescript/src/__tests__/TestExample.test.tsx +0 -31
- package/templates/ui/typescript/src/setupTests.ts +0 -2
package/lib/constants/package.js
CHANGED
|
@@ -19,11 +19,14 @@ const uiDependencies = {
|
|
|
19
19
|
const jsUiDevDependencies = {
|
|
20
20
|
'@corva/dc-platform-shared': 'latest',
|
|
21
21
|
'@corva/eslint-config-browser': 'latest',
|
|
22
|
-
'@testing-library/jest-dom': '^5.
|
|
23
|
-
'@testing-library/react': '12.1.5',
|
|
22
|
+
'@testing-library/jest-dom': '^5.14.1',
|
|
23
|
+
'@testing-library/react': '^12.1.5',
|
|
24
24
|
'@testing-library/react-hooks': '^8.0.1',
|
|
25
|
-
'@testing-library/user-event': '^
|
|
26
|
-
'
|
|
25
|
+
'@testing-library/user-event': '^13.2.1',
|
|
26
|
+
'jest-watch-typeahead': '^1.0.0',
|
|
27
|
+
'jest': '^27.4.3',
|
|
28
|
+
'babel-jest': '^27.4.2',
|
|
29
|
+
'babel-preset-react-app': '^10.0.1',
|
|
27
30
|
'eslint': '7.32.0',
|
|
28
31
|
'postcss-loader': '4.1.0',
|
|
29
32
|
};
|
|
@@ -33,8 +36,8 @@ const tsUiDevDependencies = {
|
|
|
33
36
|
'@tsconfig/create-react-app': '1.0.2',
|
|
34
37
|
'@types/material-ui': '0.21.9',
|
|
35
38
|
'@types/react': '^17.0.22',
|
|
36
|
-
'@types/jest': '26.0.24',
|
|
37
39
|
'@types/react-dom': '^17.0.9',
|
|
40
|
+
'@types/jest': '^27.0.1',
|
|
38
41
|
'@typescript-eslint/eslint-plugin': '^4.31.2',
|
|
39
42
|
'@typescript-eslint/parser': '^4.31.2',
|
|
40
43
|
'ts-loader': '8.2.0',
|
|
@@ -47,7 +50,8 @@ const uiScripts = {
|
|
|
47
50
|
zip: 'create-corva-app zip .',
|
|
48
51
|
lint: 'eslint --cache ./src/',
|
|
49
52
|
release: 'create-corva-app release .',
|
|
50
|
-
test: '
|
|
53
|
+
test: 'jest',
|
|
54
|
+
coverage: 'jest --coverage',
|
|
51
55
|
};
|
|
52
56
|
|
|
53
57
|
const uiPackage = {
|
|
@@ -56,10 +60,38 @@ const uiPackage = {
|
|
|
56
60
|
scripts: uiScripts,
|
|
57
61
|
dependencies: uiDependencies,
|
|
58
62
|
devDependencies: jsUiDevDependencies,
|
|
59
|
-
// TODO: This is a temporary workaround. Should be removed once
|
|
60
|
-
// this ticket is resolved: https://corvaqa.atlassian.net/browse/DC-3982
|
|
61
63
|
jest: {
|
|
62
|
-
|
|
64
|
+
roots: ['<rootDir>/src'],
|
|
65
|
+
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts'],
|
|
66
|
+
coverageThreshold: {
|
|
67
|
+
global: {
|
|
68
|
+
branches: 60,
|
|
69
|
+
functions: 60,
|
|
70
|
+
lines: 60,
|
|
71
|
+
statements: 60,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
setupFilesAfterEnv: ['<rootDir>/config/jest/setupTests.js'],
|
|
75
|
+
globalSetup: '<rootDir>/config/jest/globalSetup.js',
|
|
76
|
+
testMatch: ['<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}', '<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}'],
|
|
77
|
+
testEnvironment: 'jsdom',
|
|
78
|
+
transform: {
|
|
79
|
+
'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$': '<rootDir>/config/jest/babelTransform.js',
|
|
80
|
+
'^.+\\.css$': '<rootDir>/config/jest/cssTransform.js',
|
|
81
|
+
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)': '<rootDir>/config/jest/fileTransform.js',
|
|
82
|
+
},
|
|
83
|
+
transformIgnorePatterns: [
|
|
84
|
+
'/node_modules/(?!.*@babel/runtime).+\\.(js|jsx|mjs|cjs|ts|tsx)$',
|
|
85
|
+
'^.+\\.module\\.(css|sass|scss)$',
|
|
86
|
+
],
|
|
87
|
+
modulePaths: [],
|
|
88
|
+
moduleNameMapper: {
|
|
89
|
+
'~(.*)': '<rootDir>/src/$1',
|
|
90
|
+
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
|
|
91
|
+
'@corva/ui(.*)': '@corva/ui/cjs-bundle/$1',
|
|
92
|
+
},
|
|
93
|
+
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
|
|
94
|
+
resetMocks: true,
|
|
63
95
|
},
|
|
64
96
|
};
|
|
65
97
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
const babelJest = require('babel-jest').default;
|
|
4
|
+
|
|
5
|
+
module.exports = babelJest.createTransformer({
|
|
6
|
+
presets: [
|
|
7
|
+
[
|
|
8
|
+
require.resolve('babel-preset-react-app'),
|
|
9
|
+
{
|
|
10
|
+
runtime: 'automatic',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
],
|
|
14
|
+
babelrc: false,
|
|
15
|
+
configFile: false,
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
// This is a custom Jest transformer turning style imports into empty objects.
|
|
4
|
+
// http://facebook.github.io/jest/docs/en/webpack.html
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
process() {
|
|
8
|
+
return {
|
|
9
|
+
code: 'module.exports = {};',
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
getCacheKey() {
|
|
13
|
+
// The output is always the same.
|
|
14
|
+
return 'cssTransform';
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
// This is a custom Jest transformer turning file imports into filenames.
|
|
6
|
+
// http://facebook.github.io/jest/docs/en/webpack.html
|
|
7
|
+
|
|
8
|
+
const toPascalCase = str => {
|
|
9
|
+
const allWordsIterator = str.matchAll(/\w+/g);
|
|
10
|
+
|
|
11
|
+
return Array.from(allWordsIterator).reduce((acc, matchResult) => {
|
|
12
|
+
const word = matchResult[0];
|
|
13
|
+
return acc + word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
14
|
+
}, '');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
process(src, filename) {
|
|
19
|
+
const assetFilename = JSON.stringify(path.basename(filename));
|
|
20
|
+
|
|
21
|
+
if (filename.match(/\.svg$/)) {
|
|
22
|
+
// Based on how SVGR generates a component name:
|
|
23
|
+
// https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
|
|
24
|
+
const pascalCaseFilename = toPascalCase(path.parse(filename).name);
|
|
25
|
+
const componentName = `Svg${pascalCaseFilename}`;
|
|
26
|
+
return {
|
|
27
|
+
code: `const React = require('react');
|
|
28
|
+
module.exports = {
|
|
29
|
+
__esModule: true,
|
|
30
|
+
default: ${assetFilename},
|
|
31
|
+
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
|
|
32
|
+
return {
|
|
33
|
+
$$typeof: Symbol.for('react.element'),
|
|
34
|
+
type: 'svg',
|
|
35
|
+
ref: ref,
|
|
36
|
+
key: null,
|
|
37
|
+
props: Object.assign({}, props, {
|
|
38
|
+
children: ${assetFilename}
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
}),
|
|
42
|
+
};`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { code: `module.exports = ${assetFilename};` };
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
|
4
|
+
// allows you to do things like:
|
|
5
|
+
// expect(element).toHaveTextContent(/react/i)
|
|
6
|
+
// learn more: https://github.com/testing-library/jest-dom
|
|
7
|
+
// eslint-disable-next-line
|
|
8
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
9
|
+
|
|
10
|
+
// Set UTC timezone for tests to not use the environment timezone
|
|
11
|
+
process.env.TZ = 'UTC';
|