Skip to content

test_runner (after) doesn't work on v21.7.0 #52013

@timursevimli

Description

@timursevimli

Version

node v21.7.0

Platform

macOS Sonoma 14.3.1 Darwin Kernel Version 23.3.0

Subsystem

node:test

What steps will reproduce the bug?

In version 21.7.0, the t.after method is not called and completed, unlike other versions (I tried v21.6.2 and v20.11.0)

'use strict';

const assert = require('node:assert');
const test = require('node:test');

const someListener = () => {
  let timer = setTimeout(() => {}, 9999999);
  return {
    cancel: () =>  {
      if (!timer) return;
      clearTimeout(timer);
      timer = null;
    }
  };
};

test('This test, does not complete', async (t) => {
  const listener = someListener();

  t.after(() => {
    listener.cancel();
  });

  assert.strictEqual(1, 1);
});

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

No response

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

No response

What do you see instead?

What I see on v21.7.0
Screenshot 2024-03-08 at 2 41 18 PM

What I expected:
Screenshot 2024-03-08 at 2 41 44 PM

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions