Skip to content

Boolean support is brittle #42

@kasperlewau

Description

@kasperlewau

I have two use cases that will not pass with the following versions: chai@^3.5.0, chai-things@^0.2.0 and mocha@^2.4.5.

Expect all array items to be of type boolean.

Possible duplicate of #16

const bools = [false, true, false];
expect(bools).to.all.be.a('boolean');

// ERROR: expected false to be a boolean

Workaround:

expect(bools).to.all.satisfy(bool => typeof bool === 'boolean');

Expect all array items to be true (or, false).

const truths = [true, true, true];
expect(truths).to.all.be.true;

// ERROR: expected true to be true

Workaround:

expect(truths.includes(!true)).to.be.true;

If I can find the time on my hands to get a PR rolling for this, I'd be more than happy to. If for whatever reason I can't, I'd ❤️ whomever does find the time and energy to do so!

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