-
Notifications
You must be signed in to change notification settings - Fork 111
Broken test isolation of VueRouter instances #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What I've found out so far:
We should try to break down the behavior of |
Hi! Yeah, this mostly looks like a bug on VTU' Thanks for this! |
Can you explain how to push a route on to the VueRouter created by render()? I'm trying to test a component that gets a route parameter and it currently is not working. |
@maxarndt - I opened up #238 as a proposed solution to fix this issue. I also tested it against your fork and confirmed that this fix resolves the problem you surfaced. Alternatively, as a quicker solution, you can set up a global // jest.config.js
module.exports = {
setupFilesAfterEnv: ['./jest.setup.js'],
}; // ./jest.setup.js
beforeEach(() => {
window.location.replace('http://localhost/');
}); |
🎉 This issue has been resolved in version 5.8.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@maxarndt - I ran into something weird today with the workaround I posted above. It appears that Vue Router adds a Because of this, I recommend passing an instantiated router that uses |
@blimmer thank you for your hard work on this! I tried to use an instantiated router that uses
So I ended up using a custom import { render } from '@testing-library/vue'
import VueRouter from 'vue-router'
import { routes } from '@/src/router'
import App from '@/src/App'
export async function renderApp () {
const router = new VueRouter({
mode: 'abstract',
routes,
})
const renderResult = render(App, {
routes: router,
})
await router.push('/')
return renderResult
} Do you think it's worth mentioning in the FAQ section that |
No problem! I agree that the initial |
🎉 This issue has been resolved in version 6.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Describe the bug A clear and concise description of what the bug is.
VueRouter
instances are not erased properly after completing a test case.To Reproduce Steps to reproduce the behavior:
Expected behavior
All tests should pass.
Screenshots
Related information:
@testing-library/vue
version: HEAD at 7bef579Vue
version:"vue": "^2.6.12"
node
version:v12.18.4
npm
version:6.14.9
Additional context
I just added two assertions to an already existent test case and duplicated the test to be executed twice in a row (see maxarndt@306550f).
Both tests should pass if the testing environment is cleaned up properly.
Unfortunately this is not the case.
The text was updated successfully, but these errors were encountered: