Skip to content

Commit

Permalink
chore: refactor test and silent mode
Browse files Browse the repository at this point in the history
due bug with the createroute injector the testing frameworks throws warnings until find solution i enable silent mode
  • Loading branch information
Isaac-cura committed Feb 21, 2023
1 parent 84d5b8a commit 4e746bf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel',
transformIgnorePatterns: ['/node_modules/(?!@ionic/vue|@ionic/vue-router|@ionic/core|@stencil/core|ionicons|axios)'],
setupFiles: ["jest-canvas-mock"]
setupFiles: ["jest-canvas-mock"],
silent: true
}
3 changes: 2 additions & 1 deletion src/views/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ import { onMounted } from 'vue';
import PokemonCard from '@/components/pokemon-card.vue';
import { PokemonListState } from '@/models/pokemon-store.model';
import { Pokemon } from '@/models/pokemon.model';
import { useRouter } from 'vue-router';
const pokemonListStore = usePokemonListStore()
const router = useIonRouter()
const router = useRouter()
onMounted(() => {
pokemonListStore.fetchAndUpdatePokemons(pokemonListStore.paginatorInfo)
})
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/views/home-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import { createTestingPinia } from '@pinia/testing'
import { usePokemonListStore } from '@/stores/pokemon-list.store'
import { nextTick } from 'vue'
import { dummyBulbasaurParsed } from '../dummies/bulbasaur'
import { createRouter, createWebHistory } from 'vue-router'

describe("test suite for the home page", () => {

let homePageWrapper: VueWrapper;
beforeEach(() => {
homePageWrapper = mount(HomePage, {
global: {
plugins: [createTestingPinia()]
plugins: [createTestingPinia(), createRouter({
history: createWebHistory(),
routes: [{path: '/', component: HomePage}]
})]
}
})
})
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/views/pokemon-detail-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import PokemonDetailPage from '@/views/PokemonDetailsPage.vue'
import { VueWrapper, mount } from '@vue/test-utils'
import { createTestingPinia } from '@pinia/testing';
import { usePokemonDetailStore } from '@/stores/pokemon-detail.store';
import { useRoute } from 'vue-router';
import { createRouter, useRoute } from 'vue-router';
import { dummyBulbasaurParsed } from '../dummies/bulbasaur';
import { TriggerOpTypes, capitalize, nextTick } from 'vue';
import { TriggerOptions } from '@vue/test-utils/dist/createDomEvent';
import { capitalize, nextTick } from 'vue';


jest.mock("vue-router", () => ({
useRoute: jest.fn()
Expand Down

0 comments on commit 4e746bf

Please sign in to comment.