Skip to content

Commit 47168ef

Browse files
committed
add test to check vue-router require for mocha users
1 parent b6bcf46 commit 47168ef

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/__tests__/vue-router-mocha.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import '@testing-library/jest-dom'
2+
import {render} from '@testing-library/vue'
3+
4+
import About from './components/Router/About.vue'
5+
6+
const routes = []
7+
test('uses require("vue-router").default when require("vue-router") is undefined (useful for mocha users)', () => {
8+
// Test for fix https://github.com/testing-library/vue-testing-library/issues/119
9+
jest.mock('vue-router', () => {
10+
return undefined
11+
})
12+
13+
expect(() => render(About, {routes})).toThrowError(
14+
new TypeError("Cannot read property 'default' of undefined"),
15+
)
16+
})

0 commit comments

Comments
 (0)