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

power-assert output fails when using async/await #113

Closed
jamestalmage opened this issue Oct 31, 2015 · 4 comments
Closed

power-assert output fails when using async/await #113

jamestalmage opened this issue Oct 31, 2015 · 4 comments

Comments

@jamestalmage
Copy link
Contributor

test.js

import test from 'ava';

function foo() {
    return Promise.resolve(true);
}

test('foo', async t => {
    t.plan(1);
    t.ok(await foo() === false);
});

output

  Error: Line 1: Unexpected identifier
    at Test.<anonymous> (/.../test.js:9:4)
    at step (/.../test.js:5:273)
@jamestalmage
Copy link
Contributor Author

I have cross-posted here: power-assert-js/babel-plugin-espower#6

I can't tell which library is causing the error. Please close if you are confident it is the power-assert plugin.

@twada
Copy link
Contributor

twada commented Oct 31, 2015

@jamestalmage Thank you for reporting.
And yes, this is caused by power-assert (Thank you for cross-posting this).

@twada
Copy link
Contributor

twada commented Oct 31, 2015

For now, please avoid using await expression INSIDE assertions.

Doesn't work:

test('foo', async t => {
    t.plan(1);
    t.ok(await foo() === false);
});

Would work:

test('foo', async t => {
    t.plan(1);
    const result = await foo();
    t.ok(result === false);
});

Sorry for inconvenience, I'll fix it ASAP.

@jamestalmage
Copy link
Contributor Author

Closing since the issue is in power-assert

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

No branches or pull requests

2 participants