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

"MockInstance: side effects have been detected" hard to track #1046

Closed
GerkinDev opened this issue Sep 7, 2021 · 5 comments · Fixed by #1079
Closed

"MockInstance: side effects have been detected" hard to track #1046

GerkinDev opened this issue Sep 7, 2021 · 5 comments · Fixed by #1079

Comments

@GerkinDev
Copy link

Hi there ! Hope you're doing well and that you took some time for yourself during the summer !

I've seen recently that ng-mocks triggers warnings about MockInstance incorrectly cleaned up. Thing is, I have plenty of tests, and plenty of files, so its kinda hard to find where the issue occurs. Would it be possible to add a context or something ? Or add an option so that affected test fails completely ?

🍻 cheers !

@satanTime
Copy link
Member

satanTime commented Sep 8, 2021

Hi @GerkinDev,

Yep, I still think about how to find the best way to mock them before initialization, and that jest issue, which is ignored by maintainers, spoils everything.

Usually, what I do is that I enable additional logging myself, then, at least, it helps to understand affected tests: https://github.com/ike18t/ng-mocks/blob/master/karma-test-shim.ts#L39-L46

Not sure if it's working for jest without the jasmine runner.
Please let me know if it has helped, otherwise I can add a config flag which would fail instead of a warning.

@satanTime
Copy link
Member

Also, a question. Did you configure this setup: https://ng-mocks.sudo.eu/extra/install#default-customizations? Or you use jest 27+?

@satanTime
Copy link
Member

satanTime commented Sep 12, 2021

I think I found the issue. Please check the next release once it has been published.

It was caused by

afterEach(() => MockInstance(SomeClass)); // no config didn't reset the tracker.

@GerkinDev
Copy link
Author

Hi there ! Sorry, I was quite busy laying some code to write EBNF syntax on the fly lol

I didn't had the time to try those options. I'll try it next time I leave my feature branch

Cheers !

@satanTime
Copy link
Member

v12.5.0 has been released and contains a fix for the issue. Feel free to reopen the issue or to submit a new one if you meet any problems.

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

Successfully merging a pull request may close this issue.

2 participants