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

use() function only returns plugin first time #1603

Open
ramicohen303 opened this issue Feb 13, 2024 · 1 comment · May be fixed by #1617
Open

use() function only returns plugin first time #1603

ramicohen303 opened this issue Feb 13, 2024 · 1 comment · May be fixed by #1617

Comments

@ramicohen303
Copy link

Related to #1569

I have multiple test files, each loading its own copy of chai and chai-http plugin. The first file works fine, all others fail. If I comment out the first file, the second file works fine, all others fail.

Looking at the code, I believe the issue cause is in chai.js, in the "use" function. The "used" array is global, and once a plugin is added to it, it cannot be added again. However, the exports object is instantiated on every call, but only the first instance gets the plugin.

For now, I created a factory function that returns a singleton chai and chai-http, and I use it in every test file. However, I believe this should be fixed properly.

@koddsson
Copy link
Member

@ramicohen303; could you write up a quick failing test in pseudo code for this? It would be helpful so we can make sure we are fixing the correct thing.

@koddsson koddsson linked a pull request May 14, 2024 that will close this issue
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