Skip to content

t.throws shows undefined undefined undefined when a string is thrown #661

@SamVerschueren

Description

@SamVerschueren

Description

When using t.throws() with a promise that rejects with a string instead of an Error object, the assertion fails.

import test from 'ava';

async function fn(): Promise<any> {
    return Promise.reject('foo');
}

test(async t => {
    t.throws(fn(), 'foo');
});

screen shot 2016-03-21 at 11 53 43

When using Promise.reject(new Error('foo'));, it works as expected.

It's due to these lines. I have no idea why it overrides the err reference with a function. I looked into core-assert and it doesn't seem like it works with passing in a function as the expected parameter. But might be missing something here.

Environment

Node.js v4.2.1
darwin 15.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions