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

This does not seem to work with Jest #2

Closed
oliverwatkins opened this issue Mar 3, 2020 · 2 comments
Closed

This does not seem to work with Jest #2

oliverwatkins opened this issue Mar 3, 2020 · 2 comments
Assignees
Labels
Won't fix 🙅‍♂️🙅‍♀️ This issue won't be fixed

Comments

@oliverwatkins
Copy link

If I have a jest test that looks like this :

import waitUntil from "async-wait-until";
import React from "react";

test(' test something  ', () => {
    testAutocompleteAsync();
});

async function testAutocompleteAsync() {

    await waitUntil(() => {
        return 1 == 1;
    }, 2000)
        .then((result) => {
            throw "Error!!!"
        })
        .catch((error) => {
            throw "Error!!!"
        });

    throw "Error!!!"
}

then I will get it passing all the time.

Am I using this library correctly?

@devlato
Copy link
Owner

devlato commented Apr 7, 2020

@oliverwatkins I think your test is incorrect. As far as your testAutocompleteAsync function is async, the test case should also be async. Try this:

import waitUntil from 'async-wait-until';

// Callback should be an async function if it tests async stuff
it('test something', async () => {
  await waitUntil(() => {
    return 1 == 1;
  }, 2000);

  // Something that you want to assert here?
});

@devlato devlato added the Won't fix 🙅‍♂️🙅‍♀️ This issue won't be fixed label Apr 7, 2020
@devlato devlato self-assigned this Apr 7, 2020
@devlato devlato closed this as completed Feb 1, 2021
@devlato
Copy link
Owner

devlato commented Feb 1, 2021

Closing this issue as it's not related to the library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Won't fix 🙅‍♂️🙅‍♀️ This issue won't be fixed
Projects
None yet
Development

No branches or pull requests

2 participants