-
Notifications
You must be signed in to change notification settings - Fork 40
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
Unrelated tests are bleeding into each other #65
Comments
Hey. What testing tool are you using? Mocha, Jest, etc? Please take a look at #64 if it solves your problem. |
I'm using Jest. Sorry about that. That's a pretty big detail to leave out. Let me try this and see what it does. |
Hi, I don't think this is related, but I could be doing something wrong. If you look at my example, you'll notice I am not using any instance mocks. It appears to be bleeding data across type mocks, which seems to be making the order of my tests matter. So far I have been able to work around it by changing the orders of my tests. Oddly enough, if I don't use module-scoped mocks, it still happens. What I mean is, if I create a mockClient in each test individually, I get the same behavior as if I declare them at the top and reuse them. It's the same way if I use something like lodash to clone them, so there appears to be some kind of module-level state persistence happening. |
I'm unable to reproduce the issue. I've created a simple Please see https://github.com/m-radzikowski/aws-sdk-client-mock-issue65 - fork it or make PR with changes to reproduce the issue, if you can. |
Please let me know if you reproduce the issue based on the repo I linked above, I'm unable to reproduce it. |
Thanks man! I'm really sorry I didn't get back to this in a reasonable amount of time. If it crops up again I will open a new ticket. Thanks so much and sorry to waste your time. |
Checklist
Bug description
Unrelated tests are bleeding data into each other. Both tests pass when run separately. When they are run together, "returns a generic error when dynamodb fails to delete" fails consistently with a "fake ddb scene error" that only exists in the other unrelated test. My current workaround is to put the second test above the first, which resolves it. This is likely related to the caveats in some way, though it is peculiar behavior because it seems the mock resets are ignored or don't matter. When I don't use module-level mock, and put an individual in each tests, the same problem occurs. There is an implicit global state that is hard to reason about.
Environment
Here is an example test file, in case I am doing something obviously dumb:
The text was updated successfully, but these errors were encountered: