Skip to content
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

Jest Unit Tests: modal component #4589

Closed
rodhoward opened this issue Jan 9, 2020 · 3 comments · Fixed by #4604
Closed

Jest Unit Tests: modal component #4589

rodhoward opened this issue Jan 9, 2020 · 3 comments · Fixed by #4604

Comments

@rodhoward
Copy link

@rodhoward rodhoward commented Jan 9, 2020

Hi,

We have just updated to version: 2.2.0.

Since then we have had to put in a number of ugly wait next tics etc to get our Jest unit tests to work with modals. Similar to what you have in your unit tests:

await waitNT(wrapper.vm)

Why are these now required? When can we pull them back out :)?

Cheers
Rod

@tmorehouse

This comment has been minimized.

Copy link
Member

@tmorehouse tmorehouse commented Jan 9, 2020

This is due to the nextTick required in the portalling process used by <b-modal> (and other portalled components). All updates to the modal content take a nextTick to update the portal target.

When the component runs it's updated() hook, the children are not guaranteed to be finished updating until the next Vue update tick, hence the requirement when portalling the content to the portal target

@tmorehouse

This comment has been minimized.

Copy link
Member

@tmorehouse tmorehouse commented Jan 12, 2020

PR #4604 Removes the portalling nextTick delay, but note that with the latest Vue test utils, the await nextTick is required since tests no longer run in synchronous mode. nextTicks (and requestAnimationFrame) are also required when testing elements with transition hooks (if not stubbing transitions)

jackmu95 added a commit that referenced this issue Jan 13, 2020
…lay when updating content in transporter portal (closes #4589) (#4604)

* chore: remove nextTick delay in BootstrapVue transporter portal

* Update transporter.spec.js

* Update modal.spec.js

* Update modal.spec.js

* Update modal.spec.js

* Update modal.spec.js

* Update modal.spec.js

* Update modal.spec.js

* Update modal.spec.js

* Update modal.spec.js

* Update modal.spec.js

* Update modal.spec.js

* Update transporter.js

Co-authored-by: Jacob Müller <jacob.mueller.elz@gmail.com>
@rodhoward

This comment has been minimized.

Copy link
Author

@rodhoward rodhoward commented Jan 14, 2020

Thanks for the quick responses. PR has fixed it for us :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.