Problem description
Window.open is used in the code to open a new window, and an error is reported in jest unit test
window.open(url, name, config)
jest not implemented window.open()
Solution:
Directly define the window. Open method in the test file, which should be suitable for all window methods.
window.open = jest.fn()
Note that the mockclear()
method is always called in the test file, because window.Open
is a global object and will always exist during the test.
it('test', () => {
window.open.mockClear()
wrapper.vm.handleOpen()
})