diff --git a/kolibri/core/assets/src/views/ContentRenderer/__tests__/ContentRendererError.spec.js b/kolibri/core/assets/src/views/ContentRenderer/__tests__/ContentRendererError.spec.js index 19dc789124d..4726a15b2a0 100644 --- a/kolibri/core/assets/src/views/ContentRenderer/__tests__/ContentRendererError.spec.js +++ b/kolibri/core/assets/src/views/ContentRenderer/__tests__/ContentRendererError.spec.js @@ -1,5 +1,4 @@ import { render, screen } from '@testing-library/vue'; -import VueRouter from 'vue-router'; import userEvent from '@testing-library/user-event'; import ContentRendererError from '../ContentRendererError.vue'; @@ -7,7 +6,6 @@ import ContentRendererError from '../ContentRendererError.vue'; const renderComponent = props => { return render(ContentRendererError, { props, - routes: new VueRouter(), }); }; diff --git a/kolibri/core/assets/src/views/ContentRenderer/__tests__/ContentRendererLoading.spec.js b/kolibri/core/assets/src/views/ContentRenderer/__tests__/ContentRendererLoading.spec.js index e6e2d8ca2ec..7299cf8df44 100644 --- a/kolibri/core/assets/src/views/ContentRenderer/__tests__/ContentRendererLoading.spec.js +++ b/kolibri/core/assets/src/views/ContentRenderer/__tests__/ContentRendererLoading.spec.js @@ -1,12 +1,9 @@ import { render, screen } from '@testing-library/vue'; -import VueRouter from 'vue-router'; import ContentRendererLoading from '../ContentRendererLoading.vue'; describe('ContentRendererLoading', () => { test('the component should render correctly', () => { - render(ContentRendererLoading, { - routes: new VueRouter(), - }); + render(ContentRendererLoading); expect(screen.getByRole('progressbar')).toBeInTheDocument(); }); diff --git a/kolibri/core/assets/src/views/ContentRenderer/__tests__/DownloadButton.spec.js b/kolibri/core/assets/src/views/ContentRenderer/__tests__/DownloadButton.spec.js index 7e3b443c40e..bd30637e7bb 100644 --- a/kolibri/core/assets/src/views/ContentRenderer/__tests__/DownloadButton.spec.js +++ b/kolibri/core/assets/src/views/ContentRenderer/__tests__/DownloadButton.spec.js @@ -1,6 +1,5 @@ import Vue from 'vue'; import { render, screen } from '@testing-library/vue'; -import VueRouter from 'vue-router'; import useUser, { useUserMock } from 'kolibri.coreVue.composables.useUser'; import DownloadButton from '../DownloadButton.vue'; import { RENDERER_SUFFIX } from '../constants'; @@ -35,7 +34,6 @@ const renderComponent = props => { ); return render(DownloadButton, { - routes: new VueRouter(), props: { files: [], nodeTitle: '', diff --git a/kolibri/core/assets/src/views/CoreMenu/__tests__/CoreMenuDivider.spec.js b/kolibri/core/assets/src/views/CoreMenu/__tests__/CoreMenuDivider.spec.js index 90a7765cd0f..650b1feb9b4 100644 --- a/kolibri/core/assets/src/views/CoreMenu/__tests__/CoreMenuDivider.spec.js +++ b/kolibri/core/assets/src/views/CoreMenu/__tests__/CoreMenuDivider.spec.js @@ -1,12 +1,9 @@ import { render, screen } from '@testing-library/vue'; -import VueRouter from 'vue-router'; import CoreMenuDivider from '../CoreMenuDivider.vue'; describe('CoreMenuDivider', () => { test('renders the component', () => { - render(CoreMenuDivider, { - routes: new VueRouter(), - }); + render(CoreMenuDivider); expect(screen.getByRole('listitem')).toBeInTheDocument(); }); diff --git a/kolibri/core/assets/src/views/ExamReport/__tests__/AttemptIconDiff.spec.js b/kolibri/core/assets/src/views/ExamReport/__tests__/AttemptIconDiff.spec.js index 394a8744b4b..9980b7fbb75 100644 --- a/kolibri/core/assets/src/views/ExamReport/__tests__/AttemptIconDiff.spec.js +++ b/kolibri/core/assets/src/views/ExamReport/__tests__/AttemptIconDiff.spec.js @@ -1,6 +1,5 @@ import { render, screen } from '@testing-library/vue'; import '@testing-library/jest-dom'; -import VueRouter from 'vue-router'; import { themeTokens } from 'kolibri-design-system/lib/styles/theme'; import AttemptIconDiff from '../AttemptIconDiff.vue'; @@ -14,7 +13,6 @@ const renderComponent = props => { diff: 1, ...props, }, - routes: new VueRouter(), }); }; diff --git a/kolibri/core/assets/src/views/ExamReport/__tests__/AttemptTextDiff.spec.js b/kolibri/core/assets/src/views/ExamReport/__tests__/AttemptTextDiff.spec.js index f780ab3a544..31f408c26aa 100644 --- a/kolibri/core/assets/src/views/ExamReport/__tests__/AttemptTextDiff.spec.js +++ b/kolibri/core/assets/src/views/ExamReport/__tests__/AttemptTextDiff.spec.js @@ -1,11 +1,9 @@ import { render, screen } from '@testing-library/vue'; import '@testing-library/jest-dom'; -import VueRouter from 'vue-router'; import AttemptTextDiff from '../AttemptTextDiff.vue'; const renderComponent = props => { return render(AttemptTextDiff, { - routes: new VueRouter(), props, store: { getters: { diff --git a/kolibri/core/assets/src/views/ExamReport/__tests__/TriesOverview.spec.js b/kolibri/core/assets/src/views/ExamReport/__tests__/TriesOverview.spec.js index eff15339625..56133ab690f 100644 --- a/kolibri/core/assets/src/views/ExamReport/__tests__/TriesOverview.spec.js +++ b/kolibri/core/assets/src/views/ExamReport/__tests__/TriesOverview.spec.js @@ -1,6 +1,5 @@ import { render, screen } from '@testing-library/vue'; import '@testing-library/jest-dom'; -import VueRouter from 'vue-router'; import TriesOverview from '../TriesOverview.vue'; import * as tryValidatorModule from '../utils'; @@ -33,7 +32,6 @@ const renderComponent = props => { ...defaultProps, ...props, }, - routes: new VueRouter(), mixins: [commonCoreStrings], }); }; diff --git a/kolibri/core/assets/src/views/InteractionList/__tests__/InteractionItem.spec.js b/kolibri/core/assets/src/views/InteractionList/__tests__/InteractionItem.spec.js index 37f97d9ac6b..c1c03bf9e99 100644 --- a/kolibri/core/assets/src/views/InteractionList/__tests__/InteractionItem.spec.js +++ b/kolibri/core/assets/src/views/InteractionList/__tests__/InteractionItem.spec.js @@ -1,5 +1,4 @@ import { render, screen } from '@testing-library/vue'; -import VueRouter from 'vue-router'; import { themeTokens } from 'kolibri-design-system/lib/styles/theme'; import InteractionItem from '../InteractionItem.vue'; @@ -11,7 +10,6 @@ const renderComponent = props => { return render(InteractionItem, { props: { ...defaultProps, ...props }, - routes: new VueRouter(), }); }; diff --git a/kolibri/core/assets/src/views/InteractionList/__tests__/index.spec.js b/kolibri/core/assets/src/views/InteractionList/__tests__/index.spec.js index 6bb63499274..f696ff62e39 100644 --- a/kolibri/core/assets/src/views/InteractionList/__tests__/index.spec.js +++ b/kolibri/core/assets/src/views/InteractionList/__tests__/index.spec.js @@ -1,5 +1,4 @@ import { render, fireEvent, screen } from '@testing-library/vue'; -import VueRouter from 'vue-router'; import InteractionList from '../'; const renderComponent = props => { @@ -13,7 +12,6 @@ const renderComponent = props => { ...defaultProps, ...props, }, - routes: new VueRouter(), }); }; diff --git a/kolibri/core/assets/src/views/__tests__/TotalPoints.spec.js b/kolibri/core/assets/src/views/__tests__/TotalPoints.spec.js index 13041c388a8..455dd25f537 100644 --- a/kolibri/core/assets/src/views/__tests__/TotalPoints.spec.js +++ b/kolibri/core/assets/src/views/__tests__/TotalPoints.spec.js @@ -1,4 +1,3 @@ -import VueRouter from 'vue-router'; import { render, screen, fireEvent } from '@testing-library/vue'; import TotalPoints from '../TotalPoints.vue'; import '@testing-library/jest-dom'; @@ -24,7 +23,6 @@ const getMockStore = () => { const renderComponent = store => { return render(TotalPoints, { store, - routes: new VueRouter(), }); }; diff --git a/kolibri/core/assets/src/views/sync/__tests__/ConfirmationRegisterModal.spec.js b/kolibri/core/assets/src/views/sync/__tests__/ConfirmationRegisterModal.spec.js index c6d209135e6..55f640f99aa 100644 --- a/kolibri/core/assets/src/views/sync/__tests__/ConfirmationRegisterModal.spec.js +++ b/kolibri/core/assets/src/views/sync/__tests__/ConfirmationRegisterModal.spec.js @@ -1,5 +1,4 @@ import { render, screen, fireEvent, waitFor } from '@testing-library/vue'; -import VueRouter from 'vue-router'; import { PortalResource, FacilityDatasetResource } from 'kolibri.resources'; import { ERROR_CONSTANTS } from 'kolibri.coreVue.vuex.constants'; import ConfirmationRegisterModal from '../ConfirmationRegisterModal.vue'; @@ -20,7 +19,6 @@ const renderComponent = props => { token: sampleToken, ...props, }, - routes: new VueRouter(), }); }; diff --git a/kolibri/core/assets/src/views/sync/__tests__/SelectSourceModal.spec.js b/kolibri/core/assets/src/views/sync/__tests__/SelectSourceModal.spec.js index d045e1fe6ee..ad6dde18c00 100644 --- a/kolibri/core/assets/src/views/sync/__tests__/SelectSourceModal.spec.js +++ b/kolibri/core/assets/src/views/sync/__tests__/SelectSourceModal.spec.js @@ -1,11 +1,9 @@ import { render, fireEvent, screen } from '@testing-library/vue'; -import VueRouter from 'vue-router'; import SelectSourceModal from '../SelectSourceModal.vue'; const renderComponent = props => { return render(SelectSourceModal, { props, - routes: new VueRouter(), }); }; diff --git a/kolibri/core/assets/src/views/userAccounts/__tests__/GenderDisplayText.spec.js b/kolibri/core/assets/src/views/userAccounts/__tests__/GenderDisplayText.spec.js index 685189c7b5b..874b314f6b6 100644 --- a/kolibri/core/assets/src/views/userAccounts/__tests__/GenderDisplayText.spec.js +++ b/kolibri/core/assets/src/views/userAccounts/__tests__/GenderDisplayText.spec.js @@ -1,4 +1,3 @@ -import VueRouter from 'vue-router'; import { render, screen } from '@testing-library/vue'; import { FacilityUserGender } from 'kolibri.coreVue.vuex.constants'; import GenderDisplayText from '../GenderDisplayText.vue'; @@ -6,7 +5,6 @@ import '@testing-library/jest-dom'; const renderComponent = gender => { return render(GenderDisplayText, { - routes: new VueRouter(), props: { gender, }, diff --git a/kolibri/core/assets/src/views/userAccounts/__tests__/GenderSelect.spec.js b/kolibri/core/assets/src/views/userAccounts/__tests__/GenderSelect.spec.js index b0d34b31abe..2a7e83bff49 100644 --- a/kolibri/core/assets/src/views/userAccounts/__tests__/GenderSelect.spec.js +++ b/kolibri/core/assets/src/views/userAccounts/__tests__/GenderSelect.spec.js @@ -1,12 +1,9 @@ import { render, screen, fireEvent } from '@testing-library/vue'; -import VueRouter from 'vue-router'; import GenderSelect from '../GenderSelect.vue'; import '@testing-library/jest-dom'; const renderComponent = () => { - return render(GenderSelect, { - routes: new VueRouter(), - }); + return render(GenderSelect); }; describe('GenderSelect', () => { diff --git a/packages/kolibri-tools/jest.conf/setup.js b/packages/kolibri-tools/jest.conf/setup.js index d2969794f97..ed7c848121a 100644 --- a/packages/kolibri-tools/jest.conf/setup.js +++ b/packages/kolibri-tools/jest.conf/setup.js @@ -14,6 +14,8 @@ import logging from 'kolibri.lib.logging'; import { i18nSetup } from 'kolibri.utils.i18n'; import KThemePlugin from 'kolibri-design-system/lib/KThemePlugin'; +/* eslint-disable vue/one-component-per-file */ + global.beforeEach(() => { return new Promise(resolve => { Aphrodite.StyleSheetTestUtils.suppressStyleInjection(); @@ -35,6 +37,12 @@ logging.setLevel('silent'); // Register Vue plugins and components Vue.use(Vuex); +Vue.mixin({ + beforeCreate: function() { + // This fix some problems between the VueRouter plugin, and Vue-testing-library. + this.$options.router = this.$options.router || undefined; + }, +}); Vue.use(VueRouter); Vue.use(VueMeta); Vue.use(KThemePlugin); @@ -69,3 +77,4 @@ global.flushPromises = function flushPromises() { scheduler(resolve); }); }; +/* eslint-enable vue/one-component-per-file */