Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update jest #27387

Merged
merged 24 commits into from
May 21, 2024
Merged

Conversation

VasilyStrelyaev
Copy link
Contributor

No description provided.

@VasilyStrelyaev VasilyStrelyaev marked this pull request as ready for review May 17, 2024 15:57
@@ -1,5 +1,4 @@
module.exports = {
testEnvironment: 'node',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In new jest, the default testEnvironment is node (used to be dom). So, now I removed every node value and added dom values where required

@@ -47,6 +47,7 @@
"@angular/platform-server": "16.2.0",
"@nx/jest": "^16.10.0",
"@nx/js": "^16.10.0",
"@types/jest": "^29.5.12",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to manually hoist jest and @types/jest to the top level, where @nx/jest could use them. Previously, they were hoisted by npm, but after update they are no longer hoisted automatically

"version": "24.1.2"
"version": "24.1.2",
"devDependencies": {
"ts-jest": "^29.1.2"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

devextreme-monorepo-tools were able to use ts-jest because it was hoisted to the top level by npm, when being declared as a dependency in other workspaces. After update, it is no longer hoisted. Neither are jest and @types/jest.

I manually elevated jest and @types/jest to the top level, because@nx/jest needs them there, and referenced ts-jest here.

"@types/react": "~18.0.0",
"@types/react-dom": "~18.0.0",
"del": "^3.0.0",
"gulp": "^4.0.2",
"gulp-header": "^2.0.0",
"gulp-shell": "^0.8.0",
"gulp-typescript": "^5.0.1",
"jest": "^26.6.3",
"jest-environment-jsdom": "^29.7.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the default testEnvironment is now node, this module should be imported to use dom as the environment.

@@ -6,7 +6,7 @@ describe('Logger tests', () => {

beforeEach(() => {
jest
.useFakeTimers('modern')
.useFakeTimers()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BC in jest API - now modern timers are the default ones (and the timer type is specified differently)

@@ -202,18 +201,13 @@
"validate-ts": "gulp validate-ts",
"validate-declarations": "dx-tools validate-declarations --sources ./js --exclude \"js/(renovation|__internal|.eslintrc.js)\" --compiler-options \"{ \\\"typeRoots\\\": [] }\"",
"testcafe-in-docker": "docker build -f ./testing/testcafe/docker/Dockerfile -t testcafe-testing . && docker run -it testcafe-testing",
"test-jest": "jest --coverage --runInBand",
"test-jest": "jest --no-coverage --runInBand",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled coverage temporarily to delegate its fix to the Grids Squad

@@ -9,7 +9,8 @@ const DAY_MS = 24 * HOUR_MS;

describe('Date utils', () => {
describe('addOffsets function', () => {
each`offsets | expectedResult
each`
offsets | expectedResult
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now validation of .each + template literal counts spaces before the table header

@@ -26,6 +26,9 @@
"es2017.object",
"dom"
],
"types": [
"jest"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#thestrangething, part 1
after updating jest, test files started confusing jest and jasmine types (although they were both already hoisted before, just like they are now)
so now I specified jest explicitly everywhere except angular (that uses jasmine)

"skipLibCheck": true,
"lib": [
"ES2020",
"dom"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#thestrangething, part 2
But after I rebased it onto upstream, where lib was recently cleared when Ilya bumped the compilation target, TS compiler stopped finding even Array and Object types.

Like my types: ["jest"] overrode even standard types unless they are specified explicitly in lib.

So I had to bring back some lib values to fix that.

{
files: ['*'],
parserOptions: {
project: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#thestrangething, part 3
even eslint's TypeScript parser stopped finding basic types, so it inferred any instead all of them. It was fixed by explicitly showing tsconfig files with lib to eslint with the project: true or set to the path.

alexslavr
alexslavr previously approved these changes May 20, 2024
@VasilyStrelyaev VasilyStrelyaev merged commit 13e54f8 into DevExpress:24_1 May 21, 2024
272 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants