Skip to content

Instantly share code, notes, and snippets.

@Attaulla9
Created January 16, 2023 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Attaulla9/fb27933a7da3b85f3b8d17ac2319c52f to your computer and use it in GitHub Desktop.
Save Attaulla9/fb27933a7da3b85f3b8d17ac2319c52f to your computer and use it in GitHub Desktop.
Vue test standard
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
import { shallowMount } from '@vue/test-utils'
import App from '@/App.vue' // Import Vue component to test
import axios from 'axios' // Import libraries to mock
// Mock the axios library
vi.mock("axios", () => {
return {
default: {
get: vi.fn(),
},
};
});
describe('Tests for the ... Component', () => {
let wrapper = null
beforeEach(() => {
// set any initial data and create the mocks of libraries
// render the component
wrapper = shallowMount(App)
})
afterEach(() => {
axios.get.mockReset()
wrapper.unmount()
})
it('check successful events', () => { ... })
it('check failure events', () => { ... })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment