Skip to content

test runner's clearInterval in callback does not work properly #59483

Description

@hotpineapple

Version

22

Platform

mac m1

Subsystem

test_runner

What steps will reproduce the bug?

I think test below should succeed, but it didn't.

test('clearInterval', (t) => {
    t.mock.timers.enable();
    const res = [];
    const id = setInterval(()=>{
        res.push('1')
        clearInterval(id);
    },10);

    t.mock.timers.tick(10);
    t.mock.timers.tick(10);
    t.mock.timers.tick(10);

  assert.strictEqual(res.length, 1); // fails with logs: 3 !==1
});

How often does it reproduce? Is there a required condition?

always

What is the expected behavior? Why is that the expected behavior?

test succeed

What do you see instead?

test failed

Additional information

No response

Activity

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

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