From cefc4f1f4d6e4bc7dc3ded78b30255872cb11794 Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Tue, 29 Jul 2025 16:43:52 +0800 Subject: [PATCH 1/3] chore: update launch configuration --- .vscode/launch.json | 18 ++++++++---------- test/config/jest.setup-tests.js | 8 ++++++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index c9611c096..9d8baf872 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,15 +9,15 @@ "request": "launch", "name": "Run unit tests", "runtimeExecutable": "npm", - "runtimeArgs": ["test"], + "runtimeArgs": ["run", "test:jest"], "console": "integratedTerminal" }, { "type": "node", "request": "launch", "name": "Run current test file", - "runtimeExecutable": "npx", - "runtimeArgs": ["jest"], + "runtimeExecutable": "npm", + "runtimeArgs": ["run", "test:jest", "--"], "args": ["-i", "${relativeFile}", "--testPathIgnorePatterns"], "console": "integratedTerminal" }, @@ -26,9 +26,8 @@ "request": "launch", "name": "Run selected test name", "runtimeExecutable": "npm", - "runtimeArgs": ["run-script", "test"], + "runtimeArgs": ["run", "test:jest", "--"], "args": [ - "--", "-i", "${relativeFile}", "-t", @@ -41,8 +40,8 @@ "type": "node", "request": "launch", "name": "Update current test file snapshot(s)", - "runtimeExecutable": "npx", - "runtimeArgs": ["jest"], + "runtimeExecutable": "npm", + "runtimeArgs": ["run", "test:jest", "--"], "args": [ "-i", "${relativeFile}", @@ -55,10 +54,9 @@ "type": "node", "request": "launch", "name": "Update selected test name snapshot(s)", - "runtimeExecutable": "npx", - "runtimeArgs": ["jest"], + "runtimeExecutable": "npm", + "runtimeArgs": ["run", "test:jest", "--"], "args": [ - "--", "-i", "${relativeFile}", "-t", diff --git a/test/config/jest.setup-tests.js b/test/config/jest.setup-tests.js index 9bc657193..0212420f9 100644 --- a/test/config/jest.setup-tests.js +++ b/test/config/jest.setup-tests.js @@ -66,6 +66,14 @@ beforeAll(async () => { // Replace addEventListener with mock global[obj].addEventListener = addEventListenerSpy; }); + + if (!window.HTMLElement.prototype.scrollIntoView) { + Object.defineProperty(window.HTMLElement.prototype, 'scrollIntoView', { + configurable: true, + writable: true, + value: function () {}, + }); + } }); beforeEach(async () => { From b292d8695196c7d01e119a92adbf8fa406cc48e7 Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Wed, 30 Jul 2025 11:09:00 +0800 Subject: [PATCH 2/3] fix: update scrollIntoView mock to use arrow function syntax --- test/config/jest.setup-tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/config/jest.setup-tests.js b/test/config/jest.setup-tests.js index 0212420f9..c08897464 100644 --- a/test/config/jest.setup-tests.js +++ b/test/config/jest.setup-tests.js @@ -71,7 +71,7 @@ beforeAll(async () => { Object.defineProperty(window.HTMLElement.prototype, 'scrollIntoView', { configurable: true, writable: true, - value: function () {}, + value: () => {}, }); } }); From 39dccb360a0a077d5d930e88d6a36bb5aa7b641b Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Mon, 4 Aug 2025 10:44:08 +0800 Subject: [PATCH 3/3] fix: update scrollIntoView mock to use global object --- test/config/jest.setup-tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/config/jest.setup-tests.js b/test/config/jest.setup-tests.js index c08897464..bc8a90196 100644 --- a/test/config/jest.setup-tests.js +++ b/test/config/jest.setup-tests.js @@ -67,8 +67,8 @@ beforeAll(async () => { global[obj].addEventListener = addEventListenerSpy; }); - if (!window.HTMLElement.prototype.scrollIntoView) { - Object.defineProperty(window.HTMLElement.prototype, 'scrollIntoView', { + if (!global.HTMLElement.prototype.scrollIntoView) { + Object.defineProperty(global.HTMLElement.prototype, 'scrollIntoView', { configurable: true, writable: true, value: () => {},