Skip to content
Open
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 frontends/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@faker-js/faker": "^10.0.0",
"@testing-library/react": "^16.3.0",
"enforce-unique": "^1.3.0",
"jest": "^29.7.0",
"jest": "^30.0.0",
"jest-when": "^3.7.0",
"lodash": "^4.17.21",
"ol-test-utilities": "0.0.0"
Expand Down
4 changes: 2 additions & 2 deletions frontends/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"@testing-library/jest-dom": "^6.4.8",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.12",
"@types/jest": "^30.0.0",
"@types/lodash": "^4.17.7",
"@types/node": "^24.0.0",
"@types/react": "^19.2.7",
Expand All @@ -80,7 +80,7 @@
"eslint": "8.57.1",
"eslint-config-next": "^16.1.6",
"http-proxy-middleware": "^3.0.0",
"jest": "^29.7.0",
"jest": "^30.0.0",
"jest-extended": "^7.0.0",
"jest-next-dynamic-ts": "^0.1.1",
"next-router-mock": "^1.0.2",
Comment on lines 80 to 86
Copy link

Choose a reason for hiding this comment

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

Bug: The test in CartPage.test.tsx will fail because it attempts to delete window.location, which is not permitted in the newer version of jsdom introduced by this PR.
Severity: HIGH

Suggested Fix

In CartPage.test.tsx, remove the line delete (window as any).location. Modify the location mocking logic to use Object.defineProperty() to redefine window.location without attempting to delete it first, similar to the pattern used in the setupLocationMock() helper function.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: frontends/main/package.json#L80-L86

Potential issue: The upgrade to `jest-environment-jsdom` v30, which uses `jsdom` v26,
makes the `window.location` object non-configurable. The test file `CartPage.test.tsx`
attempts to mock the location object by first executing `delete (window as
any).location`. This operation will now throw a `TypeError: Cannot delete property
'location' of #<Window>`, causing the test suite to fail at runtime. Other tests that
mock `window.location` using `Object.defineProperty()` without first deleting the
property are unaffected by this change.

Comment on lines 80 to 86
Copy link

Choose a reason for hiding this comment

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

Bug: The Jest v30 upgrade makes window.location non-configurable, which will break tests in CartPage.test.tsx and those using setupLocationMock() that attempt to mock it.
Severity: HIGH

Suggested Fix

Update the tests to mock window.location in a way that is compatible with jsdom v26+. Instead of deleting or redefining window.location, use methods like jest.spyOn(window, 'location', 'get') to mock specific properties like assign or href, or use jest.replaceProperty to replace the location object.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: frontends/main/package.json#L80-L86

Potential issue: The upgrade to Jest v30 includes an update to jsdom v26, which makes
the `window.location` object non-configurable. This change causes tests that mock
`window.location` to fail. Specifically, `CartPage.test.tsx` attempts to `delete
window.location` and then reassign it, which will fail. Additionally, the
`setupLocationMock()` utility function, used by at least eight test suites, calls
`Object.defineProperty(window, "location", ...)` which will now throw a `TypeError`.
This will cause numerous tests to fail at runtime, blocking the CI pipeline.

Expand Down
8 changes: 4 additions & 4 deletions frontends/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@testing-library/jest-dom": "^6.4.8",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.12",
"@types/jest": "^30.0.0",
"@types/jest-when": "^3.5.2",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/typescript-estree": "^8.0.0",
Expand All @@ -58,8 +58,8 @@
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-styled-components-a11y": "^2.1.35",
"eslint-plugin-testing-library": "^7.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.5.0",
"jest": "^30.0.0",
"jest-environment-jsdom": "^30.0.0",
"jest-extended": "^7.0.0",
"jest-fail-on-console": "^3.3.1",
"jest-watch-typeahead": "^3.0.1",
Expand All @@ -74,6 +74,6 @@
"typescript": "^5.5.4"
},
"dependencies": {
"@jest/environment": "^29.7.0"
"@jest/environment": "^30.0.0"
}
}
Loading
Loading