Skip to content

Commit 6ff1d04

Browse files
committed
Add cleanup to multi-test files
1 parent 89b9b26 commit 6ff1d04

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

tests/__tests__/stopwatch.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import StopWatch from './components/StopWatch.vue'
2-
import { render, wait, fireEvent } from '@testing-library/vue'
2+
import { cleanup, render, wait, fireEvent } from '@testing-library/vue'
33
import 'jest-dom/extend-expect'
44

5+
afterEach(cleanup)
6+
57
test('unmounts a component', async () => {
68
jest.spyOn(console, 'error').mockImplementation(() => {})
79

tests/__tests__/vue-router.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ import App from './components/Router/App.vue'
44
import Home from './components/Router/Home.vue'
55
import About from './components/Router/About.vue'
66

7-
import { render, fireEvent } from '@testing-library/vue'
7+
import { cleanup, render, fireEvent } from '@testing-library/vue'
88

99
const routes = [
1010
{ path: '/', component: Home },
1111
{ path: '/about', component: About },
1212
{ path: '*', redirect: '/about' }
1313
]
1414

15+
afterEach(cleanup)
16+
1517
test('full app rendering/navigating', async () => {
1618
const { queryByTestId } = render(App, { routes })
1719

tests/__tests__/vuex.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import 'jest-dom/extend-expect'
22

33
import VuexTest from './components/VuexTest'
4-
import { render, fireEvent } from '@testing-library/vue'
4+
import { cleanup, render, fireEvent } from '@testing-library/vue'
5+
6+
afterEach(cleanup)
57

68
const store = {
79
state: {

0 commit comments

Comments
 (0)