Skip to content

test: proposal common.expectsError nextTick option #29749

Closed
@ronag

Description

I would like to propose a new option for common.expectsError which will indicate whether the error can be invoked in the same tick or not, e.g.

I would like to be able to replace tests like this:

let ticked = false;
stream.write(null, common.mustCall((err) => {
  assert.strictEqual(ticked, true);
  common.expectsError(opts)(err);
}));
ticked = true;

with

stream.write(null, common.expectsError({
 ...opts,
 nextTick: true
});

Would this make sense? It's quite often that one wants to test for callback errors and that they should be invoked asynchronously.

I think this would also help us actually making sure that callbacks are invoked asynchronously.

NOTE: Can I use expectsError to test for no error?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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