Skip to content

🐛 Bug: setup should be TDD setup #5581

@brettz9

Description

@brettz9

Bug Report Checklist

  • I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
  • I have searched for related issues and issues with the faq label, but none matched my issue.
  • I have 'smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, my usage of Mocha, or Mocha itself.
  • I want to provide a PR to resolve this

Expected

In doing a final examination of the new ESM export code, I discovered there is one small fix needing to be made.

The method setup should be the TDD setup, not mocha.setup.

Actual

setup is mocha.setup, so setup cannot be used for tdd mode.

Minimal, Reproducible Example

For:

suite('My suite (context)', function () {
  suiteTeardown(() => {
    console.log('after');
  });
  teardown(() => {
    console.log('after each');
  });
  suiteSetup(() => {
    console.log('before');
  });
  setup(() => {
    console.log('before each');
  });
  test('my test (specify)', function () {
    expect(true).to.equal(true);
  });
});

..."before each" does not run.

Versions

node_modules/.bin/mocha --version: 11.7.4

node --version: v22.16.0

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: accepting prsMocha can use your help with this one!type: buga defect, confirmed by a maintainer

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions