Skip to content

Have assertions return booleans #2455

Closed
@novemberborn

Description

@novemberborn

Spurred by conversation in #2449 and #1485 we'd like for our assertions to return booleans. true when they pass, false when they fail. This does not apply to the throws() and throwsAsync() assertions.

Failing assertions will fail the test, but do not throw exceptions. This means your test does not stop executing. Usually that's fine, but there are conditions where you're about to do something that uses a lot of resources, and it's already unnecessary. Returning booleans will help with this.

The assertions are defined here:

class Assertions {

The type definition should be updated to reflect the new return type:

ava/index.d.ts

Line 41 in 18aeac6

export interface Assertions {

Some tests should be added to (or existing test updated in) https://github.com/avajs/ava/blob/master/test-tap/assert.js.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions