-
-
Notifications
You must be signed in to change notification settings - Fork 697
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
Cannot call use inside use any more #1638
Comments
Probably makes sense to avoid weird situations with multiple versions of chai (since if you didn't care about that, you would just import Let's see what @keithamus or @koddsson thinks though |
/** type {ChaiPlugin} */
export default async function(chai, utils) {
const { use } = await import('chai')
use(jestSnapshotPlugin())
} This appears to work but I'm not sure if making the plugin function async is exactly supported. And there may always be the risk of importing wrong chai in case of duplicate resolutions |
Yep, it would be a lot cleaner if you wrote your plugin as esm of course too I think you're right though and we should add this |
The plugin is esm. But it includes another to use the extra assertions and I called |
What I mean is if you did import That would be pretty clean code but wouldn't work well if for some reason there's two chai running at once |
Ah, gotcha. Of course that's an option but I try to avoid adding chai as a dependency to plugins. Especially now, that plugins should work no problem with both v4 and v5 |
I found that in v5 this is no longer possible
use
is no longer included in the argument. Can we add it to match what was possible with v4?export function use(fn) { const exports = { + use, AssertionError, util, config, expect, assert, Assertion, ...should }; if (!~used.indexOf(fn)) { fn(exports, util); used.push(fn); } return exports; };
The text was updated successfully, but these errors were encountered: