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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling the warning in 16.8 #5

Closed
aravindet opened this issue Apr 22, 2019 · 7 comments
Closed

Disabling the warning in 16.8 #5

aravindet opened this issue Apr 22, 2019 · 7 comments

Comments

@aravindet
Copy link

Hi Sunil! 馃槃

I know this is a somewhat annoying ask, but is there a good way to suppress the act() warning until 16.9 is released?

(The code I'm testing ends up creating a chain of promises, which Jest's fake timers won't run synchronously until this is merged.)

@danielkcz
Copy link

Why don't you use 16.9 alpha version? The async act should be able to take care of chain of promises.

@aravindet
Copy link
Author

I definitely agree that 16.9 would have been ideal. There's of course some circumstances specific to my project (although it can't be that rare) that factors in:

  • This needs to go into production, and the app in question has a lot of paying users so using the alpha is not really feasible.
  • Our CI is set up to fail if build/test produces warnings to console. I can't merge my otherwise working feature unless I can suppress this warning. 馃槩
  • The thing I'm working on involves some third-party libraries that schedule asynchronous tasks in a way that cannot really be trapped by Jest timer mocks.

@danielkcz
Copy link

danielkcz commented Apr 22, 2019

This needs to go into production, and the app in question has a lot of paying users so using the alpha is not really feasible.

I would say this is more of the scarecrow that a real issue. React is very stable and "alpha" doesn't mean "it's broken", but "there are some new things we want users to check out before rolling out" instead. I would even say it's intentional to test these releases in production. Imagine there is a bug that gets revealed only in your code. The "stable" 16.9 comes out, you will use it and bam, bug hits you anyway.

Furthermore, I believe that particular release is focused on act only, so it should be pretty safe regarding the actual production code. Well, if you are unwilling to put forward some trust, I am afraid you have to wait.

Alternatively, you can try jest --silent which should hide pretty much anything including act warnings. Or figure out some other way on suppressing console output in tests, it's not that hard really, eg. jest-mock-console.

@aravindet
Copy link
Author

So is there no way to just disable the "You've caused a rerender outside of act()" warning with no other effects?

@danielkcz
Copy link

AFAIK there is no such thing as it would be too tempting to just disable instead of fixing the situation :)

@threepointone
Copy link
Owner

@aravindet does jest-mock-console not unblock you? you can use it in your warning tests, and assert that only the act warning fires (and then remove it once 16.9 is released)

@aravindet aravindet changed the title Observable Disabling the warning in 16.8 Apr 22, 2019
@aravindet
Copy link
Author

@threepointone that might work, thanks!

They are already hijacking the console to add the "fail CI on output" behaviour, but I think I can double-hijack it during my tests 馃憤

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

No branches or pull requests

3 participants