0👍
window.location.href
gives you the URL of the current page;
window.location.pathname
will give you the path name of the current page, which I believe, is what you are looking for.
- [Vuejs]-The GET method is not supported for this route. Supported methods: POST. when i want to input data
- [Vuejs]-Bootstrap-Vue + Vuelidate: "Dialog" for creating and updating data
0👍
This is my Solution!
import { shallowMount } from '@vue/test-utils'
import redirectComponent from '../components/RedirectComponent.vue'
describe('Redirect component', () => {
const wrapper = shallowMount(redirectComponent)
Object.defineProperty(window, 'location', {
value: {
href: 'http://localhost',
},
configurable: true,
});
it('Redirect By Click Test', () => {
wrapper.find('.target').trigger('click');
expect(window.location.href).toEqual('/home');
})
})
Source:stackexchange.com