-
This took me some time to figure out, a documentation update might help. TLDR:
to
If you are using imperative Chai API calls like
The rest is documenting my journey to get it working again (I thought I couldn't fix this and wanted to file a bug for that): Chai stopped working in the browser. Old setup:
This now fails with
Making it a module:
Fails with
because it does no longer define the global "chai" (im using Next try:
Aaaah, got it:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
you are right, we need to update the docs (actually there's a few places we really should update asap before more people get confused) basically, moving it to an ES module means we don't expose it on a global anymore automatically so you would need to register one of the interfaces: import '../node_modules/chai/register-should.js';
// or
import '../node_modules/chai/register-assert.js'; or alternatively do what you said, import chai within your JS ( |
Beta Was this translation helpful? Give feedback.
-
Okay, would a PR on https://github.com/chaijs/chaijs.github.io help? |
Beta Was this translation helpful? Give feedback.
-
Ugh, sorry, I'd need a ruby system to run this which I don't have. Apologies, I'll not work on this. |
Beta Was this translation helpful? Give feedback.
-
Done, find it here. I also did some work after all but cannot verify it so I created a patch. See the linked comment. |
Beta Was this translation helpful? Give feedback.
you are right, we need to update the docs (actually there's a few places we really should update asap before more people get confused)
basically, moving it to an ES module means we don't expose it on a global anymore automatically
so you would need to register one of the interfaces:
or alternatively do what you said, import chai within your JS (
import {chai}
)