-
Notifications
You must be signed in to change notification settings - Fork 667
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
Removing sync mode #1137
Comments
Thanks for the explanation and better now than after v1. Just as a thought, wouldn't recommending something like this be better to make it also work when await wrapper.vm.$nextTick() Or is that irrelevant? |
You can use either, they're the same function |
As much as I liked it, thank you for sharing the detailed explanation and changing it in the beta rather than causing more refactoring work later. Also thank you for creating an issue prior to changing it! ❤️ |
@eddyerburgh can you please adjust the release https://github.com/vuejs/vue-test-utils/releases/tag/v1.0.0-beta.29 and place this under breaking changes? There's BREAKING CHANGES but it's not listed under there and I didn't notice the text at the top. |
Hey @eddyerburgh! I could be talking complete nonsense, but would it be possible to await that next tick in the i.e. instead of
do
|
Yes that's a good idea, I was thinking the same thing 👍 |
@sagalbot @eddyerburgh I don't think this was included in v1.0.0-beta.29: v1.0.0-beta.29...dev #1141 was merged on 9th of February while v1.0.0-beta.29 was already tagged on the 2nd. |
I feel like that's conflating two things: triggering the event, and flushing to the DOM. What if a tester wanted to do more than just trigger a click event before the next tick? I'd suggest instead either sticking with the original trigger/await nextTick pattern, or adding a new method, something like: await wrapper.triggerAndNextTick('click'); ... but with a less terrible name! |
Fair point. I would imagine there could be some interesting points of inspiration to take from the async utilities/patterns of |
What a change; this also broke
would trigger changes (dom, watchers, computed, etc) in the component, but now you have to do
Imo this change should be reflected in the docs asap! |
Is this change in 1.0.0-beta.29? I'm fighting #1163 and trying to figure out the best way forward. |
@garyo No, it is not—see also my comment above: #1137 (comment) |
What a mess, release notes are telling lies then.... I had to update the test-utils, and now I'm getting all sorts of errors on tests that where succeeding before. There is something really wrong with the DOM updates when ran with test-utils. Are there other things I can check to resolve these issues? |
@dietergeerts I don't see this mentioned in the release notes. 🤔
It probably helps to create a new issue with reproduction steps and the error message. |
https://github.com/vuejs/vue-test-utils/releases/tag/v1.0.0-beta.29
It's very confusing |
@eddyerburgh I agree with @dietergeerts that this entry in the release notes could have some clarification. It reads as if |
Just to keep you guys up-to-date: When reverting to By using the test utils, are there any connection on global level? |
* Remove waitFor from QualityChooser Use `v-if`s instead * [bundle] * Convert QualityChooser test to async test vuejs/vue-test-utils#1137
- Fixed a bug (vuejs/vue-test-utils#1137) - Remove unnecessary warning when running unit tests
- Fixed a bug (vuejs/vue-test-utils#1137) - Remove unnecessary warning when running unit tests
Is there a way to pin docs online at a certain version? The reason I ask is that when using Vuetify, tests can blow up when running in However when reading through the docs of I support the idea of removing sync updates because it goes against the grain of Vue, and Node JS in general, so I'm glad that it's gone. However I think it would be helpful for people to be able to view the docs online for the version of the library they're using. Especially for breaking changes like this. |
The only way I see is to point to that version on Netlify. |
I upgraded @vue/test-utils to version `v1.0.0-beta.31`. We were previously on `v1.0.0-beta25`, here's the changelog: - https://github.com/vuejs/vue-test-utils/releases This upgrade broke a bunch of tests; our tests had to refactored to run asynchronously, here are some links regarding that: - vuejs/vue-test-utils#1137 - https://vue-test-utils.vuejs.org/guides/#writing-asynchronous-tests-using-nexttick-new Refs: #2380
I upgraded @vue/test-utils to the latest version, `v1.0.0-beta.31`. We were previously on `v1.0.0-beta25`, here's the changelog: - https://github.com/vuejs/vue-test-utils/releases This upgrade broke a bunch of tests; our tests had to refactored to run asynchronously, here are some links regarding that: - vuejs/vue-test-utils#1137 - https://vue-test-utils.vuejs.org/guides/#writing-asynchronous-tests-using-nexttick-new Refs: #2380
I upgraded @vue/test-utils to the latest version, `v1.0.0-beta.31`. We were previously on `v1.0.0-beta25`, here's the changelog: - https://github.com/vuejs/vue-test-utils/releases This upgrade broke a bunch of tests; our tests had to refactored to run asynchronously, here are some links regarding that: - vuejs/vue-test-utils#1137 - https://vue-test-utils.vuejs.org/guides/#writing-asynchronous-tests-using-nexttick-new Refs: #2380
* Update @vue/test-utils I upgraded @vue/test-utils to the latest version, `v1.0.0-beta.31`. We were previously on `v1.0.0-beta25`, here's the changelog: - https://github.com/vuejs/vue-test-utils/releases This upgrade broke a bunch of tests; our tests had to refactored to run asynchronously, here are some links regarding that: - vuejs/vue-test-utils#1137 - https://vue-test-utils.vuejs.org/guides/#writing-asynchronous-tests-using-nexttick-new Refs: #2380 * Remove package-lock.json Using both `package-lock.json` and `yarn-lock.json` can cause confusion and lead to potential issues, so we'll just use one, `yarn-lock.json`. :smile: Refs: #2380
* Use address autocomplete As it used to be. Also defaults place edit map to be group centre if available. * Remove uneeded extra wrapped div * Update setup for storyshots testing "sync: false" seems to be the new way it goes and will be the default in the future, see vuejs/vue-test-utils#1137 The transition group stubs seem to be there by default now too, I think.. Anyway it works where it did no tbefore :) Also see vuejs/vue-test-utils#1163 * Add @types/jest - for editor support See https://blog.jetbrains.com/webstorm/2018/10/testing-with-jest-in-webstorm/ * Increase test wait Not really sure why this changed, but don't want to think about it for now... * Add text to translation file * Use the spelling of the enemy * Simplify template logic
* Initial work to add person-to-person sharing * A few sharing item UI refinements * Initial new sharing form with multiple upload * Add a grey box... * Remove redundant check * Rename sharing to offers * Add a mock chat to offer detail UI * Create mobile version of offer detail UI * Tidy up multiple image editing * A bit more polish on the offer UI Some translations, icon, breadcrumb, etc... * Snapshot update * Add create offer breadcrumb title * Rename a few offer related things for consistency * Offer image carousel, multi upload, various bits * Refine image upload/remove/re-position * Add websocket listeners for offer changes * Wireup offer conversation * Basic features to allow to accept/archive offers * Remove uneeded demo data * Move selected offer data/logic to own store module * Preserve offer filter in more places The create/save filter preservation does not work actually as we clear the store contents on route change. * Remove status from offer form Status change is now done via explicit actions/buttons * Use address autocomplete (#1878) * Use address autocomplete As it used to be. Also defaults place edit map to be group centre if available. * Remove uneeded extra wrapped div * Update setup for storyshots testing "sync: false" seems to be the new way it goes and will be the default in the future, see vuejs/vue-test-utils#1137 The transition group stubs seem to be there by default now too, I think.. Anyway it works where it did no tbefore :) Also see vuejs/vue-test-utils#1163 * Add @types/jest - for editor support See https://blog.jetbrains.com/webstorm/2018/10/testing-with-jest-in-webstorm/ * Increase test wait Not really sure why this changed, but don't want to think about it for now... * Add text to translation file * Use the spelling of the enemy * Simplify template logic * Ffix multicroppa * Further refine offer editing, esp MultiCroppa * Use gift as offers menu item * Remove offer upload progress logging * Nicer create offer button * Clear offerDetail on route leave * Add offer list loading indicator * Add offer body loading indicator * Add loading spinner when fetching offer for edit * Correctly wire up offer form reset events * Only show offer accept/archive buttons if active * Handle updating offers after save/websocket better * Cleaner mobile form view * Only show carousel if >1 image * Fix offer header when name is very long * Fix offer detail image display when only 1 * Fix overflowing text on group offers page * White background offer description * Snapshot update * Don't try and be fancy with updating users * Fix style style * Hide offers if group does not have the feature * Check route features in after route hook * Actually filter offers by current group * Add offers covert function to convert createdAt * Display offer information in latest messages I did it a slightly different way, by adding related offers into the latestMessages state... * Keep related offers up to date via websocket It's a bit overkeen actually as most users won't be in the conversations for the offers, so we don't need to update the related item... should really check we need it first * Import default offer status from store * Use current route query instead of getter * Use + for new offer button * Allow setting new_offer notification types * Show offer status if not active Although it's a bit ugly * Change notification type spinner * Add group.features to test mocks * Wrap settings forms in FormContainer * Rename to KFormContainer and move to base * Add confirm step to accept/archive offer buttons * Use photo icon for offer image placeholder * Add offer as a "fake" empty result * Filter offers by status and sort by createdAt desc ... entries can get added via websockets that might not fit the filter, and might need reordering * Refine group offer cards - use QImg instead of lots of CSS - use QItem inside for nicer layout * Correct RouterLink casing * Update test snapshots * Please the pedantic linter * Remove offer description helper * Extract mapErrors to statusMixin * Add accept/archive text into i18n * Remove unneeded code * Add offer filter status text to i18n * Correct size for new offer button * Remove one layer of div soup * Put the group offer cards in proper links * Remove commented out code * Convert offer in websocket update * Prefix functional getter with get For getNotificationTypeStatus * Preserve route query when clicking on offer conv * Use icon service for latest messages offer item * Move withoutKeys to utils * Use invisible class instead of custom css * Don't put const value in data * Save disk space by compacting template * Remove unneeded v-model Was only used when I tried out quasar :rules * Document MultiCroppa value prop a bit more * Document the data that latestMesages/related has
Removed sync mode from vueTestUtils, since (it has been removed)[vuejs/vue-test-utils#1137]. Also add the import of flushPromises(). It took quite some time to find out that it was an external package.
Removed sync mode from vueTestUtils, since (it has been removed)[vuejs/vue-test-utils#1137]. Also add the import of flushPromises(). It took quite some time to find out that it was an external package.
Prior to the 1.0.0 release, @vue/test-utils made a few breaking changes: * The "sync mode" was removed in vuejs/vue-test-utils#1137, meaning that we have to explicitly call nextTick() before checking if something has changed in the DOM * transition is no longer automatically stubbed, we have to create our own transitionStub.
Prior to the 1.0.0 release, @vue/test-utils made a few breaking changes: * The "sync mode" was removed in vuejs/vue-test-utils#1137, meaning that we have to explicitly call nextTick() before checking if something has changed in the DOM * transition is no longer automatically stubbed, we have to create our own transitionStub.
After searching for an alternative solution, we've decided to remove synchronous updating (sync mode) from Vue Test Utils.
tl;dr
We will remove sync mode in the next beta version. Test code will change from this:
To this:
Background
By default, Vue batches updates to run asynchronously (on the next "tick"). This is to prevent unnecessary DOM re-renders, and watcher computations (see the docs for more details).
When we started Vue Test Utils, we decided to make updates run synchronously. The reasoning was that synchronous tests are easier to write, and have improved error handling.
For context, the decision was made just after async/await had been released in node 7.6, so asynchronous tests often looked like this:
Because of this decision Vue Test Utils runs updates synchronously by default. That was a mistake.
Why?
Sync mode causes bugs that don't exist when Vue runs normally. This is frustrating for users, and bad functionality for a testing framework that's intended to give you confidence that your code will work in production.
We went through three different approaches to implement sync mode. Each had problems. The final attempt was to reimplement synchronous updates in Vue core, but there were still bugs caused by synchronous updates.
Solution
The solution is to remove sync mode entirely from Vue Test Utils and rely on the user explicitly waiting for updates to be applied:
This will be a big change for many test suites. You have two choices:
We recommend that you update your tests in order to benefit from future features of Vue Test Utils. This will also make your tests more robust since Vue will perform updates in the same way as it does in production.
To make the migration as smooth as possible, so we'll provide documentation and guides to help you write tests asynchronously with
Vue.nextTick
.Finally, I'm sorry for the work this change will require. I was a large part of the driving force for running in sync mode by default, and I underestimated the problems that it would cause.
Going forward, this will improve the stability of Vue Test Utils, and we'll be able to release a stable API as v1.
The text was updated successfully, but these errors were encountered: