Skip to content

Too aggressive in declaring the test "finished" #1327

@jamestalmage

Description

@jamestalmage

The following works in 0.18.2:

test(t => {
	t.notThrows(new Promise(resolve => {
		setTimeout(() => {
			t.pass();
			resolve();
		}, 100);
	}));
});

On master, it fails with:

Assertion passed, but test has already ended

We should wait until all pending assertions have resolved before declaring a test "finished" and throwing when new assertions show up.

Adding a call to t.plan() causes it to behave oddly going all the way back (we even added a test solidifying this odd behavior in #360):

test(t => {
   t.notThrows(new Promise(resolve => {
       t.plan(2);
       setTimeout(() => {
         t.pass();
         resolve();
       }, 100);
   }));
});

The above fails with:

Planned for 2 assertions, but got 1.

Similar results for as far back as I tested.

I think we should allow for added assertions, as long as we still have pending assertions. When t.plan is used, I don't think we should check for too few assertions until we've drained all pending assertions.

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