-
Notifications
You must be signed in to change notification settings - Fork 668
v1.1.4 regression #1820
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
Here's another example for a failing test after upgrading to 1.1.4 import SupportFaq from '@/views/SupportFaq'
import { routes } from '@/router'
jest.mock('@/views/SupportFaq.vue', () => ({
name: 'SupportFaq',
render: h => h('div'),
}))
it('works in 1.1.3 fails in 1.1.4', async () => {
const router = new VueRouter({ routes })
const localVue = createLocalVue()
localVue.use(VueRouter)
const wrapper = mount(
{
template: '<router-view/>',
},
{
localVue,
router,
},
)
await router.push('/support/faq')
expect(wrapper.findComponent(SupportFaq).exists()).toBe(true)
}) |
Interesting, what on earth would have caused this I wonder. |
Actually, no I don't wonder, I bet it is this: #1817 I cannot look few a few days, if someone wants to try reverting that commit and see if that's the problem? This seems like it's pretty important to fix and patch asap. |
@lmiller1990 reverting these two changes in 1.1.4 fixes my problem with the posted example above. The change in line 59-65 in matches.js breaks my test. |
If we just revert it, we will break the issue it was trying to fix. What I think we should do is
Are you interested in making this change? |
@lmiller1990 I'll give it a try. |
@lmiller1990 I can't reproduce the error. I wrote a test #1832 like @Ky6uk posted. Unfortunately the test succeeds. I used his example because mine is more complex. Maybe I miss something. |
I confirm, could not reproduce a failing test with both the examples provided in this issue. I'm not sure if all information was provided in them for us to be able to reproduce |
Ok I was able to create a failing test in #1832 depending on my posted example! I added some comments because I encountered some problems. Please have a look @BeeMargarida. I still have no clue what causes it. |
@Bastczuak I think this is another problem not related to the changes made in #1817, even with the regression the test continues to fail (only with shallowMount)...hum. If I'm understanding this correctly 😅 |
@BeeMargarida Yes, but that should be normal behaviour because |
@Bastczuak Yes, you are right 😄
So, I think I found the problem. The "old" logic checked if the selector was functional and, if not, used the So, for this use case, we need the child, but for the test made in the other PR we need the ("new" logic with the test case created by @Bastczuak, in this case the TLDR: when using the |
Hello, would this by chance have affected v1.1.1? At my job, we've had router tests that have passed for 7-8 months until this past week where things have just failed out of nowhere. We haven't even touched the codebase either within the past 2 weeks. |
@leungk712 no, this was introduced in 1.1.4 according to the bug report. You must have changed something (updating the dependencies?) Regarding " I don't know how to unstub using shallowMount" - you can't, it's shallowMount. The point is to stub all the things. @BeeMargarida great investigation. Is there any reason we cannot just revert to the previous logic, then add in the additional code that was added in the PR that caused this regression? That (should) cover all the cases (I think... the shallowMount and findComponent logic is so complicated, I would need to re-familiarize myself with it). |
@lmiller1990 We can maintain the old logic (and fix this bug) and support the use case added in the PR #1817 if we changed this test
wrapper.find({ name: 'test-functional-component', functional: true }).exists() . But I don't know if it goes against the feature added in the PR.
|
@BeeMargarida @lmiller1990 Ok I updated my merge request #1832 with a really naive approach, but all tests pass now. Oh and btw, I am sorry, I didn't really know why the commit hooks failed using webstorm. Now I know that my commit messages are crap. I guess I have to create a new merge request later. |
After upgrade to 1.1.4 one of our thousands tests also fails. We don't know why, because the one is pretty similar to other working tests. How we can test the new new version of 1.1.4? |
Thanks for the PR @Bastczuak, I will give this a look today. @stefpb if you could test this out with your code base, that would be great! You could just clone this repo, Could you please do this? That would give me more confidence when releasing this patch. |
Yes, i did exactly what you said, but it has the same behavior: One Test out of our thousend tests now fails. So for the user view nothing changed. Don't work for me :/ |
Are you sure you built the PR and not the current dev branch? The PR doesn't even build for me (same as CI), so you probably did not test the fix.
I cloned the PR, fixed the build error and tested it. Out of 54 failed tests with plain 1.1.4, 53 worked again. I think those were all related to RouterView. I do have one remaining failing test where I do |
Ah, could be! I did this steps: Outside the project:
Again inside the project: Run again tests, but then 1 tests failed. How i can checkout the code of the PR? |
Instead of cloning the official repo, clone @Bastczuak's fork:
then proceed the same way. (Alternatively add this repo as a remote, if you know how to do it) |
Right, you will need the fork with the branch. Let me know when you try it out. If it is successful, I can merge and release straight away. |
Have you read my message above? I tested it, too - and it does not solve the regression fully, yet. |
Right, I missed your message. I see - one bug remaining. Can you share the failing test (ideally, simplify it as much as possible). Is it just: import { RouterLinkStub } from '@vue/test-utils'
const Comp = {
stubs: { RouterLink: RouterLinkStub },
template: `<router-link to="/foo" />`
}
shallowMount(Comp).getComponent(RouterLinkStub) ? We can add it to this code base (probably with the current PR) and get this merged and released. I think it should not be too difficult once we have a reproduction. Weird it's only a RouterLinkStub test failing. That's the only component we export. I wonder if that's related. Are you using this exported component or a default stub? |
Didn't have the time to make it a reproducible test-case, but I use this:
and
The getComponent fails now, but passed before. I'm sure the component is still rendered. |
Yeah, that's about it, not much more to it. If it doesn't fail for you, I can dig deeper. |
This is working perfectly for me: it.only('findComponent on a RouterLinkStub', () => {
const Comp = {
name: 'Comp',
template: `<router-link to="/foo" />`
}
const wrapper = mountingMethod(Comp, {
stubs: {
RouterLink: RouterLinkStub
},
})
wrapper.getComponent(RouterLinkStub)
}) Will need a reproducible test case. If we cannot solve by the end of the week, we can release what we have and keep exploring. If you can reproduce the problem I can take a look. |
Right. I copied your test into my codebase - works, too! I noticed my component, that uses Changing your test to: it.only('findComponent on a RouterLinkStub', () => {
const Comp = {
name: 'Comp',
functional: true,
render (h) { return h('router-link', { props: { to: "/foo" } }) }
}
const wrapper = mountingMethod(Comp, {
stubs: {
RouterLink: RouterLinkStub
},
})
wrapper.getComponent(RouterLinkStub)
}) makes it fail for me, similar to my test-case. I tried the following as well, but this results in a different error: it.only('findComponent on a RouterLinkStub', () => {
const Comp = {
name: 'Comp',
functional: true,
template: `<router-link to="/foo" />`
}
const wrapper = mountingMethod(Comp, {
stubs: {
RouterLink: RouterLinkStub
},
})
wrapper.getComponent(RouterLinkStub)
}) results in
|
This seems to be unrelated to it.only('findComponent in functional component', () => {
const Comp2 = {
name: 'test',
render (h) { return h('div', 'test') }
}
const Comp = {
name: 'Comp',
functional: true,
render (h) { return h(Comp2) }
}
const wrapper = shallowMount(Comp, {
})
wrapper.getComponent(Comp2)
}) This fails for me. In both 1.1.4 and the open PR. Confirmed again: This very test-case passes just fine in 1.1.3. |
I see. So the problem is related to |
Worked on this a bit: #1835 Grabbed some code from @Bastczuak's branch and the regressions here. This part of the code base is so complicated. I just added all the tests cases and wrote code until they all passed ✅ 🤞 CI passes. |
@wolfgangwalther @stefpb could either of you pull and build this branch and run it against your code-bases? #1835 There is one test with routing that fails on versions < 2.6. I am not entirely sure why, the matching logic so complicated, I just added all the regressions and hacked until it passed. |
Works for me, all tests pass. |
@lmiller1990 I also can confirm that all tests pass in my code-base with your branch. |
Great, I will test a bit more and release a new version this weekend. |
Some tests are only failing on CI, but not locally. Please wait a bit all - I need to figure out what's going on... |
Ok, it's out: https://github.com/vuejs/vue-test-utils/releases/tag/v1.2.0 A little nervous, I hope we did not introduced any more regressions. Please test and let me know how this goes. |
When i try
And also the new version 1.2.0 have the same behavior. So for me it isn't solved :/ |
@stefpb can you post a minimal reproduction? All the tests are passing for the all reproductions in this thread - I think you mentioned you have a problem with |
In this special case the test emits on a component that is also a stub. We used the selector for the child component, which isn't there anymore, when we upgrade to vue-test-utils 1.1.4. But now we use the stub-selector and now the test is passing. |
since updating to 1.1.4 (or greater) my unit tests are now breaking - I have a custom component (renderer) which renders form components (e.g. input, text area, checkbox etc) dynamically using a config provided via props. The component iterates through the config and renders the inputs (mapping them to appropriate vue components) - now in my test when i do the following:
I should get true from the test expectation but now im getting false. When i downgrade to 1.1.3 everything works fine and the tests pass. |
@ravjsdev thanks for the bug report. Since it seems there's a bunch of edge cases, let's solved them one by one. Please open a new issue with your exact reproduction. I cannot reproduce your issue with your comment alone. Thanks! |
Subject of the issue
After upgrading from
v1.1.3
tov1.1.4
some tests have started to fail.Steps to reproduce
Expected behaviour
Tests should pass as it was before the upgrade.
Actual behaviour
Tests failed.
Possible Solution
Downgrade to
v1.1.3
.The text was updated successfully, but these errors were encountered: