From 21db731b22aa6d2ea14ff0192edc1434029e7ef1 Mon Sep 17 00:00:00 2001 From: Thomas Arrow Date: Mon, 24 Aug 2026 16:03:12 +0100 Subject: [PATCH] tests: unit tests fix warnings and errors This patch uses two workarounds from stackoverflow to prevent warnings that seem to be present after updating jest. While the unit tests have always worked in CI and still work locally without this patch there is a lot of unnecessary noise which prevents easily running them locally Bug: T435838 --- tests/unit/about.spec.js | 1 + tests/unit/boilerplate.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/unit/boilerplate.js diff --git a/tests/unit/about.spec.js b/tests/unit/about.spec.js index dad7e009..8177ac5d 100644 --- a/tests/unit/about.spec.js +++ b/tests/unit/about.spec.js @@ -1,5 +1,6 @@ import { shallowMount } from '@vue/test-utils' import About from '@/components/Pages/About.vue' +require('./boilerplate.js') describe('About.vue', () => { it('renders some text', () => { diff --git a/tests/unit/boilerplate.js b/tests/unit/boilerplate.js new file mode 100644 index 00000000..8af23246 --- /dev/null +++ b/tests/unit/boilerplate.js @@ -0,0 +1,18 @@ +// Necessary boilerplate to prevent errors and warnings with newer versions of jest + +// See: https://stackoverflow.com/a/60731669 +import Vuetify from 'vuetify' +import Vue from 'vue' +Vue.use(Vuetify) + +// See: https://stackoverflow.com/a/59904516 + +// jest and afterEach defined as globals to keep eslint happy +/* global jest, afterEach */ +const assignMock = jest.fn() +delete window.location +window.location = { assign: assignMock } + +afterEach(() => { + assignMock.mockClear() +})