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

Docs issues galore with ESM vs CommonJS use #1654

Closed
delfuego opened this issue Nov 24, 2024 · 1 comment · Fixed by chaijs/chaijs.github.io#215
Closed

Docs issues galore with ESM vs CommonJS use #1654

delfuego opened this issue Nov 24, 2024 · 1 comment · Fixed by chaijs/chaijs.github.io#215

Comments

@delfuego
Copy link

The primary docs site is replete with issues related to the use of Chai, specifically in terms of the differences between Chai 4 and Chai 5.

For example, there are still plenty of places that read that one should use:

import chai from 'chai';

when the Chai 5 ESM-only version doesn't have a default exported object, so that fails. It took me a while to figure out that everything is now a named export, so if I want to use a plugin, I have to use:

import { use, expect } from 'chai';

and then change all my chai.use() calls to just use that newly-exported use method.

Is there a Chai 5/ESM-only doc page that helps folks make these changes?

@boly38
Copy link

boly38 commented Dec 7, 2024

with your help and request issue help, here is a working sample of import adapted to ESM+chai5 that work for me (I'm not chai expert)

import {should, use as chaiUse} from 'chai';
import chaiHttp from 'chai-http';
import deepEqualInAnyOrder from 'deep-equal-in-any-order';

should();
chaiUse(deepEqualInAnyOrder);
const chaiRequest = chaiUse(chaiHttp);
// chaiRequest.request...

but it would be much better if official doc follows chai engine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants