Skip to content

Commit

Permalink
chore: Upgrade jest (#3589)
Browse files Browse the repository at this point in the history
* Upgrade jest and ts-jest

* Fix jsdom environment issue

* Upgrade babel-jest. Fix grid packages tests

* Fix tests in material-ui grid

* Fix scheduler packages tests

* Fix chart packages test environment

* Fix most of unit tests. Temporary skip failed tests

* Fix chart core animation tests

* Fix jest config warnings

* Rebuild lock file after merge

* Upgrade api-extractor to use newer version of TypeScript

* Revert "Upgrade api-extractor to use newer version of TypeScript"

This reverts commit 3d3b694.

* Upgrade api extractor. Fix its issues

* Fix api extractor error

* Fix async checks in tests
  • Loading branch information
timbset authored Nov 3, 2022
1 parent 82f11bb commit 7aeee1b
Show file tree
Hide file tree
Showing 56 changed files with 1,912 additions and 1,344 deletions.
3 changes: 2 additions & 1 deletion api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"enabled": true
},
"compiler" : {
"tsconfigFilePath": "packages/<unscopedPackageName>/tsconfig.json"
"tsconfigFilePath": "packages/<unscopedPackageName>/tsconfig.json",
"skipLibCheck": true
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"license": "SEE LICENSE IN README.md",
"devDependencies": {
"@microsoft/api-extractor": "^7.6.1",
"@microsoft/api-extractor": "7.20.0",
"@types/react-test-renderer": "^16.0.0",
"check-node-version": "^4.0.1",
"concurrently": "^5.0.0",
Expand Down
11 changes: 5 additions & 6 deletions packages/dx-chart-core/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
module.exports = {
preset: 'ts-jest',
globals: {
'ts-jest': {
tsConfig: './tsconfig.json',
diagnostics: false,
},
},
testEnvironment: 'jsdom',
transform: {
'^.+\\.jsx?$': '../../tools/setup-babel-jest.js',
'^.+\\.tsx?$': ['ts-jest', {
tsconfig: './tsconfig.json',
diagnostics: false,
}],
},
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
transformIgnorePatterns: [
Expand Down
5 changes: 3 additions & 2 deletions packages/dx-chart-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@
"@types/d3-scale": "^4.0.2",
"@types/d3-shape": "^2.1.0",
"core-js": "^3.4.1",
"jest": "^24.9.0",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.2.2",
"rollup": "^1.27.2",
"rollup-plugin-license": "^0.12.1",
"rollup-plugin-typescript2": "^0.30.0",
"ts-jest": "^24.1.0",
"ts-jest": "^29.0.3",
"tslib": "^2.4.1",
"tslint": "^5.20.1",
"tslint-config-airbnb": "^5.11.2",
Expand Down
9 changes: 4 additions & 5 deletions packages/dx-chart-core/src/utils/animation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ describe('build animation', () => {
const duration = 3;
const processAnimation = jest.fn().mockReturnValue(() => 'processedAnimation');
const setAttributes = jest.fn();

beforeEach(() => {
requestAnimationFrame = jest.spyOn(window, 'requestAnimationFrame')
.mockImplementation(time => time(0) as any);
cancelAnimationFrame = jest.spyOn(window, 'cancelAnimationFrame').mockImplementation();
jest.useFakeTimers();
requestAnimationFrame = jest.spyOn(window, 'requestAnimationFrame');
cancelAnimationFrame = jest.spyOn(window, 'cancelAnimationFrame');
});

afterEach(() => {
Expand All @@ -22,8 +23,6 @@ describe('build animation', () => {
jest.clearAllMocks();
});

jest.useFakeTimers();

it('should run animation', () => {
const animation = buildAnimation(easing, duration)(
'startCoords', 'endCoords', processAnimation, setAttributes,
Expand Down
3 changes: 2 additions & 1 deletion packages/dx-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@
"devDependencies": {
"@rollup/plugin-replace": "^2.3.1",
"core-js": "^3.4.1",
"jest": "^24.9.0",
"jest": "^29.2.2",
"prettier": "^1.19.1",
"rollup": "^1.27.2",
"rollup-plugin-license": "^0.12.1",
"rollup-plugin-typescript2": "^0.30.0",
"ts-jest": "^29.0.3",
"tslib": "^2.4.1",
"tslint": "^5.20.1",
"tslint-config-airbnb": "^5.11.2",
Expand Down
26 changes: 14 additions & 12 deletions packages/dx-core/src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,17 @@ describe('utils', () => {
.not.toHaveProperty('onDoubleClick');
});

it('should call onClick event with delay', () => {
it('should call onClick event with delay', async () => {
const payload = { data: 1 };
const events = createClickHandlers(clickEvent);

events.onClick(payload);

setTimeout(() => {
expect(clickEvent)
.toHaveBeenCalledWith(payload);
}, DELAY);
await new Promise((resolve) => {
setTimeout(resolve, DELAY);
});

expect(clickEvent).toHaveBeenCalledWith(payload);
});

it('should return onDblClick function if onDblClick event is define', () => {
Expand All @@ -110,18 +111,19 @@ describe('utils', () => {
.toHaveBeenCalledWith(payload);
});

it('should not call onClick event if onDblClick event called', () => {
it('should not call onClick event if onDblClick event called', async () => {
const events = createClickHandlers(clickEvent, dblClickEvent);

events.onClick();
events.onDoubleClick();

expect(dblClickEvent)
.toHaveBeenCalled();
setTimeout(() => {
expect(clickEvent)
.not.toHaveBeenCalled();
}, DELAY);
expect(dblClickEvent).toHaveBeenCalled();

await new Promise((resolve) => {
setTimeout(resolve, DELAY);
});

expect(clickEvent).not.toHaveBeenCalled();
});
});
});
13 changes: 6 additions & 7 deletions packages/dx-grid-core/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
const path = require('path');

module.exports = {
preset: 'ts-jest',
globals: {
'ts-jest': {
tsConfig: './tsconfig.json',
diagnostics: false, // set to true to enable type checking
},
transform: {
'^.+\\.jsx?$': '../../tools/setup-babel-jest.js',
'^.+\\.tsx?$': ['ts-jest', {
tsconfig: './tsconfig.json',
diagnostics: false,
}],
},
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
testMatch: [
Expand Down
3 changes: 2 additions & 1 deletion packages/dx-grid-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@
"@rollup/plugin-replace": "^2.3.1",
"@types/exceljs": "^1.3.0",
"core-js": "^3.4.1",
"jest": "^24.9.0",
"jest": "^29.2.2",
"rollup": "^1.27.2",
"rollup-plugin-license": "^0.12.1",
"rollup-plugin-typescript2": "^0.30.0",
"seamless-immutable": "^7.1.4",
"ts-jest": "^29.0.3",
"tslib": "^2.4.1",
"tslint": "^5.20.1",
"tslint-config-airbnb": "^5.11.2",
Expand Down
5 changes: 5 additions & 0 deletions packages/dx-react-bootstrap4/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ module.exports = {
setupFiles: [
path.join(__dirname, './setup-enzyme.js'),
],
testEnvironment: 'jsdom',
transform: {
'^.+\\.jsx?$': '../../tools/setup-babel-jest.js',
'^.+\\.tsx?$': 'ts-jest',
},
transformIgnorePatterns: [
'/node_modules/(?!(d3|d3-scale|d3-array|d3-interpolate|d3-color|d3-format|d3-time|d3-time-format|internmap)/)',
],
Expand Down
1 change: 1 addition & 0 deletions packages/dx-react-chart-bootstrap4/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
moduleNameMapper: {
'.css$': path.join(__dirname, './css-stub.js'),
},
testEnvironment: 'jsdom',
setupFiles: [
path.join(__dirname, './setup-enzyme.js'),
],
Expand Down
5 changes: 3 additions & 2 deletions packages/dx-react-chart-bootstrap4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"babel-jest": "^29.2.2",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"core-js": "^3.4.1",
"enzyme": "3.10.0",
Expand All @@ -72,7 +72,8 @@
"eslint-plugin-jest": "^23.0.4",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.16.0",
"jest": "^24.9.0",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.2.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-test-renderer": "^17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/dx-react-chart-demos/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"plugins": ["@babel/plugin-transform-runtime"],
"presets": [
["@babel/preset-env", {
"modules": "commonjs",
"modules": "commonjs"
}]
]
}
Expand Down
1 change: 1 addition & 0 deletions packages/dx-react-chart-demos/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
'^.+\\.jsx?$': '../../tools/setup-babel-jest.js',
'^.+\\.tsx?$': 'ts-jest',
},
testEnvironment: 'jsdom',
transformIgnorePatterns: [
'/node_modules/(?!(d3|d3-scale|d3-array|d3-interpolate|d3-color|d3-format|d3-time|d3-time-format|d3-scale-chromatic|internmap)/)',
'/dist/',
Expand Down
7 changes: 4 additions & 3 deletions packages/dx-react-chart-demos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"babel-jest": "^29.2.2",
"babel-loader": "^8.0.6",
"concurrently": "^5.0.0",
"css-loader": "^3.2.0",
Expand All @@ -89,13 +89,14 @@
"eslint-plugin-jest": "^23.0.4",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.16.0",
"jest": "^24.9.0",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.2.2",
"mustache": "^3.1.0",
"node-static": "^0.7.11",
"nodemon": "^1.19.4",
"react-test-renderer": "^17.0.2",
"style-loader": "^1.0.0",
"ts-jest": "^24.1.0",
"ts-jest": "^29.0.3",
"ts-loader": "^8.2.0",
"typescript": "^4.8.4",
"webpack": "^4.41.2",
Expand Down
1 change: 1 addition & 0 deletions packages/dx-react-chart-material-ui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
setupFiles: [
path.join(__dirname, './setup-enzyme.js'),
],
testEnvironment: 'jsdom',
transform: {
'^.+\\.jsx?$': '../../tools/setup-babel-jest.js',
},
Expand Down
5 changes: 3 additions & 2 deletions packages/dx-react-chart-material-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"babel-jest": "^29.2.2",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"core-js": "^3.4.1",
"enzyme": "3.10.0",
Expand All @@ -73,7 +73,8 @@
"eslint-plugin-jest": "^23.0.4",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.16.0",
"jest": "^24.9.0",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.2.2",
"jss": "^10.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
11 changes: 5 additions & 6 deletions packages/dx-react-chart/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ module.exports = {
setupFiles: [
path.join(__dirname, './setup-enzyme.js'),
],
testEnvironment: 'jsdom',
snapshotSerializers: ['enzyme-to-json/serializer'],
preset: 'ts-jest',
globals: {
'ts-jest': {
tsConfig: './tsconfig.json',
diagnostics: false, // set to true to enable type checking
},
},
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
testMatch: [
'**/*.test.(ts|tsx)',
],
transform: {
'^.+\\.jsx?$': '../../tools/setup-babel-jest.js',
'^.+\\.tsx?$': ['ts-jest', {
tsconfig: './tsconfig.json',
diagnostics: false,
}],
},
transformIgnorePatterns: [
'/node_modules/(?!(d3|d3-scale|d3-array|d3-interpolate|d3-color|d3-format|d3-time|d3-time-format|internmap)/)',
Expand Down
5 changes: 3 additions & 2 deletions packages/dx-react-chart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
"core-js": "^3.4.1",
"enzyme": "3.10.0",
"jest": "^24.9.0",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.2.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-test-renderer": "^17.0.2",
"rollup": "^1.27.2",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-license": "^0.12.1",
"rollup-plugin-typescript2": "^0.30.0",
"ts-jest": "^24.1.0",
"ts-jest": "^29.0.3",
"tslib": "^2.4.1",
"tslint": "^5.20.1",
"tslint-config-airbnb": "^5.11.2",
Expand Down
1 change: 1 addition & 0 deletions packages/dx-react-core/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
setupFiles: [
path.join(__dirname, './setup-enzyme.js'),
],
testEnvironment: 'jsdom',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
Expand Down
5 changes: 3 additions & 2 deletions packages/dx-react-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
"core-js": "^3.4.1",
"enzyme": "3.10.0",
"jest": "^24.9.0",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.2.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-test-renderer": "^17.0.2",
"rollup": "^1.27.2",
"rollup-plugin-license": "^0.12.1",
"rollup-plugin-typescript2": "^0.30.0",
"ts-jest": "^24.1.0",
"ts-jest": "^29.0.3",
"tslib": "^2.4.1",
"tslint": "^5.20.1",
"tslint-config-airbnb": "^5.11.2",
Expand Down
1 change: 1 addition & 0 deletions packages/dx-react-grid-bootstrap3/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ module.exports = {
setupFiles: [
path.join(__dirname, './setup-enzyme.js'),
],
testEnvironment: 'jsdom',
};
5 changes: 3 additions & 2 deletions packages/dx-react-grid-bootstrap3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"babel-jest": "^29.2.2",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"core-js": "^3.4.1",
"enzyme": "3.10.0",
Expand All @@ -70,7 +70,8 @@
"eslint-plugin-jest": "^23.0.4",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.16.0",
"jest": "^24.9.0",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.2.2",
"react": "^17.0.2",
"react-bootstrap": "=0.33.1",
"react-dom": "^17.0.2",
Expand Down
1 change: 1 addition & 0 deletions packages/dx-react-grid-bootstrap4/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ module.exports = {
transform: {
'^.+\\.jsx?$': '../../tools/setup-babel-jest.js',
},
testEnvironment: 'jsdom',
};
Loading

0 comments on commit 7aeee1b

Please sign in to comment.