Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With new node:test package, before/beforeEach/after/afterAll don't seem to work #44528

Closed
robogeek opened this issue Sep 6, 2022 · 2 comments

Comments

@robogeek
Copy link

robogeek commented Sep 6, 2022

Version

18.8.0

Platform

Linux davidpc 5.15.0-41-generic #44-Ubuntu SMP Wed Jun 22 14:20:53 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

node:test

What steps will reproduce the bug?

I created the following code:

import {
    describe, it, before, beforeEach, after, afterEach
} from 'node:test';
import * as assert from 'node:assert';

describe('Describe Container', function() {
    before(() => { console.log('IN BEFORE')});
    beforeEach(() => { console.log('IN BEFORE EACH')});

    it('should equal 1 and 1', () => { assert.equal(1, 1); });
    it('should equal 2 and 2', () => { assert.equal(2, 2); });

    after(() => { console.log('IN AFTER')});
    afterEach(() => { console.log('IN AFTER EACH')});
});

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

Every time

What is the expected behavior?

Appropriate test output, with BEFORE, etc, messages printed

What do you see instead?

$ node --test test-before.mjs 
TAP version 13
# Subtest: /home/david/Projects/nodejs/node-test/test-before.mjs
ok 1 - /home/david/Projects/nodejs/node-test/test-before.mjs
  ---
  duration_ms: 0.074160944
  ...
1..1
# tests 1
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 0.134743581

Additional information

No response

@himself65
Copy link
Member

Refs: #44372

@himself65
Copy link
Member

Closing as there are many duplicated issues like this

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

No branches or pull requests

2 participants