Skip to content

Throws returns the promise #127

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

Merged
merged 1 commit into from
Nov 4, 2015
Merged

Throws returns the promise #127

merged 1 commit into from
Nov 4, 2015

Conversation

SamVerschueren
Copy link
Contributor

Finally found the solution for #123

By returning the promise, it's possible to check the throwed error like this which succesfully waits untill the promise is resolved/rejected.

test(async t => {
    await t.throws(throws(), /hello world/);

    function throws() {
        return new Promise(function (resolve, reject) {
            setTimeout(function () {
                reject(new Error('hello world'));
            }, 2000);
        });
    }
});

@vadimdemedes
Copy link
Contributor

lgtm

@sindresorhus?

sindresorhus added a commit that referenced this pull request Nov 4, 2015
@sindresorhus sindresorhus merged commit 8d84f39 into avajs:master Nov 4, 2015
@sindresorhus
Copy link
Member

Looks good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants