Skip to content

Better spy assertion errors #715

@imjacobclark

Description

@imjacobclark

When the following is not satisfied:

it('should call response.header with expected arguments', function(){
    let response = chai.spy.object([ 'header' ]);
    let responseBuilder = new ResponseBuilder(response);

    responseBuilder
        .addHeaderByKeyValue('Access-Control-Allow-Origin', '*')
        .build({});

    expect(response.header).to.have.been.called.with({
        'Access-Control-Allow-Origin': '*'
    });
});

It yields the below error:

AssertionError: expected { Spy 'object.header', 1 call } to have been called with [ Array(1) ]

This is not particularly helpful in seeing where the assertion actually failed, whilst the above error is correct, is there any mechanism or switch to make this more 'verbose'? If not, could this be a feature request?

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