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

Async API like "waitForElementVisible(selector, [timeout])" #174

Closed
JYC-99 opened this issue Nov 14, 2017 · 4 comments
Closed

Async API like "waitForElementVisible(selector, [timeout])" #174

JYC-99 opened this issue Nov 14, 2017 · 4 comments

Comments

@JYC-99
Copy link

JYC-99 commented Nov 14, 2017

Perhaps similar to: https://www.npmjs.com/package/enzyme-wait

@JYC-99
Copy link
Author

JYC-99 commented Nov 14, 2017

I dont find how can I do this check for now

@eddyerburgh
Copy link
Member

eddyerburgh commented Nov 14, 2017

I don't think we should add this to vue-test-utils. Waiting for promises/ timeouts to resolve isn't a vue specific problem. I'm happy to discuss this though because a few people have requested a similar feature.

You can wait for promises to resolve using flush-promises.

import flushPromises from 'flush-promises'

test('an async component', async () => {
  const wrapper = mount(AsyncComponent)
  await flushPromises()
  expect(wrapper.contains('div')).toBe(true)
})

@JYC-99
Copy link
Author

JYC-99 commented Nov 14, 2017

@eddyerburgh Thanks for explaining and I see your points.

I'm using setTimeout/_.defer to work around which seems exactly what flush-promises does.

@lmiller1990
Copy link
Member

lmiller1990 commented Nov 14, 2017

I second this shouldn't be in vue-test-utils. This is a common request - but I think people really asking "how do I do this" rather than "make the feature".

I think the best solution is a guide in the docs how on to deal with async.

Edit: see #151 .

@JYC-99 JYC-99 closed this as completed Nov 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants