-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
vue-test-utils > 1.0.0-beta.12 fails with vee-validate #1267
Comments
If I remove the name attribut from But, if i add anything as an attribut, for instance: <test
aaaa
v-model="testData"
v-validate="'required'"></test> Then I have the same error. |
There is no place in the source code where It could be some weird interaction between vee-validate and other plugin or the test environment but your test seems very similar to the ones being used in this repo except that they do not fail. I will try few things and report back if it can be fixed. |
Having the exact same issue! (except on my side It's a route component, so I don't have any custom attributes) Any progress on this @SwannLV? |
No not yet sorry, I was not working since then. If I do find I would post the solution. |
I have the same issue after updating @vue/cli dependencies from beta.6 to beta.9. When removing the prop v-validate the errors goes away. Needless to say that the validation stops working. Any progress on this? |
@cesalberca Seems you talk about |
No, I meant |
@cesalberca Weird, on my side I just got rid of the error by downgrading My tests are still failing, but I also made a big migration from Finally, I'm not really sure that |
OK, finally @logaretm even And actually even by forcing version to |
@Akaryatrh yeah, for some reason the version didn't downgrade. I fixed that and I reverted to |
It seems this issue is likely related to this one: vuejs/vue-test-utils#382 as we are using TypeScript and we need to use Vue.extend. |
I did notice that the tests fail with the test utils > 10. I didn't have
time to fully investigate it but since the tests were passing then it
should not fail with the new version, at least from VeeValidate side.
I will try to appropriately figure out what goes wrong in a couple of days
once I get back and report back.
… |
@logaretm Well, I can't find the differences between your setup and mine, but I can't make your tests pass with test utils beta 10. I even used fixed versions on the package.json file, but no luck: 8 tests are failing (with both |
The issue is that my tests fail for a different reason. For whatever
reason, the getAttribute methods gets called on null elements which is
wierd since null or headless fields are correctly handled. And there is a
bunch of unit tests to cover it.
It's likely a bug in Vue test utils, but again I will investigate once I
get back.
|
I installed However, I tried running the
We can safely say that the upgrade of The models.js should pass, but it doesn't because for some reason the watcher doesn't fire when the model value changes from null to empty string, changing the value to an intermediate value then back to an empty string fixed the test. But again it shouldn't fail unless I'm missing a critical change in how Vue compares initial values and what constitutes a change in model value. Now with the "should pass" tests out of the way, while valueResolvers pass, it produces the error reported by @SwannLV and demonstrates the strange behavior of using any props on the template, for example using At this point I ran out of ideas, and I suspect fixing vuejs/vue-test-utils#532 would address this issue. Feel free to post any updates you may come across. |
Great investigation, thx @logaretm |
as of 1.0.18 this is not yet fixed |
Issue won't be resolved before Vue 2.6 anyway as said here: vuejs/vue-test-utils#676 |
I had a similar issue with jest+vue-test-utils+vee-validator. Downgrading vue-test-utils did not work as suggested in various forums. I had to downgrade vee-validate to 2.0.9 to make it work. |
@mkhanal the beta releases had bugs due to the huge rewrite, Depending on what you are testing you could see different results between the betas and the latest stable version. Beta.5 should be passing though as the main reactivity issue was resolved. |
for me tests works with beta.5 and 1.0.0-beta.12 |
If you need |
@constantm thank you!!! I can confirm that with all the latest versions of everything: vue/cli 3.2.0 That adding the sync:false to the mount/shallowMount config, running the tests with async, and adding:
after the mount call, that the tests are working and not producing any errors. I created a sample app using the cli and added the minimal amount to reproduce the errors and the solution here: https://github.com/chriszrc/vue-veevalidate-jest-fail/tree/master/myapp The first test that doesn't use the above fixes fails with dozens of |
Hello, I tried using your example with the fixes as a guide, but I am still getting the Maximum call stack size exceeded error. Here is my test:
This part may or may not be relevant?
|
@bglaz all looks good to me, hopefully one of the experts on here can pick this up, I don't have any other ideas. Are you sure you're using all the same dependency versions? vue/cli 3.2.0 |
@chriszrc My versions are just slightly different, so maybe that has something to do with it? vue/cli 3.1.3 |
Fwiw, I upgraded test-utils to 1.0.0.-beta.27 and it's still working- |
Oh, did you try clearing the jest cache: package.json
|
I realized my issue was that I had a previous test that was NOT using sync: false and flushPromise, and that was causing all the errors. |
@bglaz hahahaha I totally did that to myself too, lol, should have mentioned that, glad you got it solved- |
I use vue-test-utils 1.0.0.-beta.28 and i don't get the max stack error when using sync: false, however, I have this problem: #1177 even though I test as described here: https://github.com/baianat/vee-validate/blob/master/tests/integration/model.js#L13 |
@agcty I've not been able to successfully test anything using vee-validate without having sync set to true. The reason for this is that there are promises that have not yet returned errors before the test finishes, hence the need for using |
@agcty with sync set to false, you might need to wait for the nextTick() to complete before checking veevalidate, since it's an asynchronous operation:
after you've changed values, but before you expect to see something vee-validate related change- |
@chriszrc Nope still doesn't work, my code looks like this: test("validates form", async () => {
const wrapper = mount(LoginForm, {
store,
localVue,
sync: false,
attachToDocument: true
});
await wrapper.vm.$nextTick();
expect(wrapper.vm.errors.count()).toBe(0);
wrapper.setData({
authData: { username: "somevalue", password: "HelloHello1!" }
});
await wrapper.vm.$nextTick();
expect(wrapper.vm.errors.has("email")).toBe(true); //always false
expect(wrapper.vm.errors.count()).toBe(0); //always 0
}); I also tried using await flushPromises() instead of await nextTick() but it makes no difference 🤔 EDIT: Need to mention that the data property is called username but the input name is email and the username should be formatted as an email so errors.has("email") should be true after setting username to "somevalue" |
The vue-test-utils have decided to drop the I added a testing guide to the docs. |
Versions:
Description:
Hi. I am having some trouble
mounting
a component which validate acustom component
withJest
andVee-Validate
. When I am not unit testing, the components and validations work great.Having those errors when running my test:
(more details at the end)
Thank you very much in advance for your help.
Steps To Reproduce:
Here is the component I am unit testing,
Step1.vue
:Here is the custom component under vee-validation,
test.vue
:And here is my
Step1.spec.js
:Error message:
The text was updated successfully, but these errors were encountered: