Skip to content

Replace jest.fn() with vi.fn() in legend tests#5163

Merged
junedchhipa merged 2 commits intomainfrom
copilot/update-vitest-test-spies
Feb 16, 2026
Merged

Replace jest.fn() with vi.fn() in legend tests#5163
junedchhipa merged 2 commits intomainfrom
copilot/update-vitest-test-spies

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

Replace inconsistent jest.fn() usage with vi.fn() in Vitest tests for better framework alignment.

Changes

  • tests/unit/legend.spec.js: Replace 3 instances of jest.fn() with vi.fn() in onLegendClick test suite
- const legendClickSpy = jest.fn()
+ const legendClickSpy = vi.fn()

While the setup shim provides jest as a global alias to vi, direct usage of Vitest's API is more explicit and consistent with the testing framework.

Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"Using 'jest.fn()' in Vitest tests is inconsistent. Use 'vi.fn()' from Vitest instead for better consistency with the testing framework.","fixFiles":[{"filePath":"tests/unit/legend.spec.js","diff":"diff --git a/tests/unit/legend.spec.js b/tests/unit/legend.spec.js\n--- a/tests/unit/legend.spec.js\n+++ b/tests/unit/legend.spec.js\n@@ -746,7 +746,7 @@\n   // =========================================================================\n   describe('onLegendClick', () => {\n     it('should not proceed when customLegendItems is set', () => {\n-      const legendClickSpy = jest.fn()\n+      const legendClickSpy = vi.fn()\n \n       const chart = chartWithLegend({\n         series: [\n"}]},{"message":"Using 'jest.fn()' in Vitest tests is inconsistent. Use 'vi.fn()' from Vitest instead for better consistency with the testing framework.","fixFiles":[{"filePath":"tests/unit/legend.spec.js","diff":"diff --git a/tests/unit/legend.spec.js b/tests/unit/legend.spec.js\n--- a/tests/unit/legend.spec.js\n+++ b/tests/unit/legend.spec.js\n@@ -746,7 +746,7 @@\n   // =========================================================================\n   describe('onLegendClick', () => {\n     it('should not proceed when customLegendItems is set', () => {\n-      const legendClickSpy = jest.fn()\n+      const legendClickSpy = vi.fn()\n \n       const chart = chartWithLegend({\n         series: [\n@@ -770,7 +770,7 @@\n     })\n \n     it('should fire legendClick event callback when legend item is clicked', () => {\n-      const legendClickSpy = jest.fn()\n+      const legendClickSpy = vi.fn()\n \n       const chart = chartWithLegend({\n         series: [\n@@ -791,7 +791,7 @@\n     })\n \n     it('should fire markerClick callback when a legend marker is clicked', () => {\n-      const markerClickSpy = jest.fn()\n+      const markerClickSpy = vi.fn()\n \n       const chart = chartWithLegend({\n         series: [\n"}]},{"message":"Using 'jest.fn()' in Vitest tests is inconsistent. Use 'vi.fn()' from Vitest instead for better consistency with the testing framework.","fixFiles":[{"filePath":"tests/unit/legend.spec.js","diff":"diff --git a/tests/unit/legend.spec.js b/tests/unit/legend.spec.js\n--- a/tests/unit/legend.spec.js\n+++ b/tests/unit/legend.spec.js\n@@ -791,7 +791,7 @@\n     })\n \n     it('should fire markerClick callback when a legend marker is clicked', () => {\n-      const markerClickSpy = jest.fn()\n+      const markerClickSpy = vi.fn()\n \n       const chart = chartWithLegend({\n         series: [\n"}]}]

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: junedchhipa <17950663+junedchhipa@users.noreply.github.com>
Copilot AI changed the title [WIP] Update test spies to use vi.fn() for consistency Replace jest.fn() with vi.fn() in legend tests Feb 14, 2026
Copilot AI requested a review from junedchhipa February 14, 2026 17:03
@junedchhipa junedchhipa marked this pull request as ready for review February 16, 2026 17:28
@junedchhipa junedchhipa merged commit 1947d56 into main Feb 16, 2026
4 of 11 checks passed
@junedchhipa junedchhipa deleted the copilot/update-vitest-test-spies branch February 16, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants