-
Notifications
You must be signed in to change notification settings - Fork 108
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
Does not work with other plugins when chai loaded multiple times #70
Comments
This is working as intended. Generally you should only add a plugin once in a given Node program. |
Thanks for the reply, and makes sense and agree in general...and chai itself maintains a list of already added plugins to make subsequent However, chai-as-promised seems a little different from other plugins in that it modifies the behavior of existing assertions. I wonder if anyone using this project can suggest a best-practice for a test spec that has chai-as-promised + another plugin and can be run on its own and with other test specs...all the options I can think of are inelegant. It makes sense to me for each test spec to require the plugins it uses rather than some wrapping thing have fore-knowledge of what chai plugins would be needed in the aggregate. |
I haven't really tried it yet but on top of my mind what if in a Apologies if this question sounds very dumb - in advance! |
Hi,
I've created my own chai plugin with custom assertions. In order to get it working with chai-as-promised I found I needed to load my custom plugin first in my test spec (Mocha via NodeJs) and then chai-as-promised:
The above works fine if its the only spec running. If I switch the order of the
use
statements then chai-as-promised does not hook my custom assertions and they get fed unresolved promises.The problem is that if I load multiple spec files, and the ones loaded first use chai-as-promised but not my custom assertions, then
chai.use()
does nothing as the chai-as-promised library has already done its stuff and my custom assertions are no longer hooked and modified by chai-as-promised.Spec 1 in Node/Mocha process:
Spec 2 in same Node/Mocha process:
Suggestions? Make sense?
The text was updated successfully, but these errors were encountered: