Open
Description
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
If you have a file setup.js
:
import { use } from "chai";
use((await import("sinon-chai")).default);
use((await import("chai-as-promised")).default);
and you execute mocha with mocha --require "setup.js"
, chai
should be able to make assertions on promises, etc
Actual
trying to do something like expect(Promise.resolve("foo")).to.become("foo")
will result in Error: Invalid Chai property: become. Did you mean "below"?
Minimal, Reproducible Example
Detailed above
Versions
mocha>=11.7.0, including 11.7.1
Additional Info
I am guessing it has to do with the recent change to use require
, which doesn't support top level await. I don't have much insight into how require(ESM)
works, but on mocha<11.7.0 the above snippet worked (probably because it was imported
, thus allowing for top level await?)