karma-runner / karma-mocha

A Karma plugin. Adapter for Mocha testing framework.
MIT License
379 stars 94 forks source link

Unit tests are missing when `script type="module"` takes >= 3ms before `describe` #243

Open loynoir opened 3 years ago

loynoir commented 3 years ago

Repo

https://github.com/loynoir/reproduce-karmaMocha-237.mjs

Scenario

Reproduce

$ npm install
$ npm test

Expected

Three tests

  CJS
    ✔ bar
  fastESM
    ✔ bar
  slowESM
    ✔ bar

SUMMARY:
✔ 3 tests completed

Actual

Missing unit test slowESM, but exit with code 0.

  CJS
    ✔ bar
  fastESM
    ✔ bar

SUMMARY:
✔ 2 tests completed
loynoir commented 3 years ago

If top level await use <3ms, unit test seems OK. 🤔

https://github.com/loynoir/reproduce-karmaMocha-237.mjs/blob/master/test/fastESM.spec.mjs#L5