You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And then I don't bother importing expect in various test files and everything worked great prior to chai v5. Since going to chai v5, I get Error: Invalid Chai property: called.
Workaround
I found a workaround by not using chai/register-expect.js, but it seems odd I have to do this. I haven't been able to find any information indicating what I'm doing wrong or if this is a known issue.
Remove chai/register-expect.js from mocha config
Add globalThis.expect = expect to test/setup/test-libs.ts
I should add it works just fine if I explicitly import expect again in the spec files instead of using the global expect. As best I can tell, it is as if register-expect.js and all my other imports are getting two different copies of expect or the Assertion prototype. No idea why that would be the case.
Problem
My mocha setup has traditionally looked something like this:
mocha config excerpt
test/setup/test-libs.ts
test/unit/example.spec.ts
And then I don't bother importing expect in various test files and everything worked great prior to chai v5. Since going to chai v5, I get
Error: Invalid Chai property: called.
Workaround
I found a workaround by not using chai/register-expect.js, but it seems odd I have to do this. I haven't been able to find any information indicating what I'm doing wrong or if this is a known issue.
globalThis.expect = expect
to test/setup/test-libs.tsmocha config excerpt
test/setup/test-libs.ts
test/unit/example.spec.ts
The text was updated successfully, but these errors were encountered: