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

🐛 Bug: Test titles not shown for ES dynamic imports #5139

Open
3 of 4 tasks
nicholaswmin opened this issue Apr 19, 2024 · 0 comments
Open
3 of 4 tasks

🐛 Bug: Test titles not shown for ES dynamic imports #5139

nicholaswmin opened this issue Apr 19, 2024 · 0 comments
Labels
status: in triage a maintainer should (re-)triage (review) this issue type: bug a defect, confirmed by a maintainer

Comments

@nicholaswmin
Copy link

nicholaswmin commented Apr 19, 2024

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

Grouping tests using dynamic imports under a describe block would show them grouped under it's test title.

i.e this:

describe('Rate Limiting', async () => {
  await import('./conn.spec.js')
  await import('./event.spec.js')
})

would show up as this:

✔ Rate Limiting
    Connections
      ✔ Rejects further handshake attempts
    Events
      ✔ Disconnects client if rate limit exceeded

Actual

Does not show outer describe test title. Instead it reports the run like this:

Connections
  ✔ Rejects further handshake attempts
Events
  ✔ Disconnects client if rate limit exceeded

Minimal, Reproducible Example

// index.spec.js
describe('Rate Limiting', async () => {
  await import('./conn.spec.js')
  await import('./event.spec.js')
})
// conn.spec.js
describe('Connections', () => {
  it ('does some handshake-y thing', () => {
    // some test
  })
})
// event.spec.js
describe('Events', () => {
  it ('does some thing with rate limiting', () => {
    // some test
  })
})

and run:

mocha index.spec.js

Versions

  • Mocha: v10.4.0
  • Node: v21.0.0
  • OS: Mac OS Sonoma v14.4.1

Additional Info

CommonJS modules don't seem to have this issue. This works out fine, no problem.

describe('Rate Limiting', () => {
  require('./conns.spec.cjs')
  require('./event.spec.cjs')
})
@nicholaswmin nicholaswmin added status: in triage a maintainer should (re-)triage (review) this issue type: bug a defect, confirmed by a maintainer labels Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: in triage a maintainer should (re-)triage (review) this issue type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

1 participant