Skip to content

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Nov 22, 2017

This is necessary for running a subset of tests against flat bundles.
I added a global unstable flag to avoid exposing yet another injection for error reporting.

Not ideal, but it works and can serve as an escape hatch to #11098.

They are making it harder to test compiled bundles.

One of them (FeatureFlags) is not used. It is mocked in some specific test files (and that's fine).

The other (FiberErrorLogger) is mocked to silence its output. I'll look if there's some other way to achieve this.
It is intended to be used in tests in cases when you intentionally throw errors and don't want to repeat the same assertions about warnings.

We don't promise to support it indefinitely.
Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an improvement

__REACT_UNSTABLE_SUPPRESS_ERROR_LOGGING__ === true
) {
return false;
}
Copy link
Contributor

@bvaughn bvaughn Nov 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙃

return (
  typeof __REACT_UNSTABLE_SUPPRESS_ERROR_LOGGING__ === 'undefined' ||
  __REACT_UNSTABLE_SUPPRESS_ERROR_LOGGING__ !== true
);

Edit for clarity: This is just a nit. It seems like you could combine the if-condition-return into just a return.

@gaearon
Copy link
Collaborator Author

gaearon commented Nov 22, 2017

I mean... I could also look into some magic to suppress these warnings at the test site. For example by adding toThrowAndWarnInDev. Or even overriding the default toThrow behavior to ignore last warning if its message matches.

Adding this magic will probably make tests more confusing if we ever want to change logging behavior. But the upside is all the hacks are isolated to our tests, and won't affect Prepack etc.

@gaearon gaearon changed the title Remove global mocks Remove global mocks by adding a global flag Nov 23, 2017
@gaearon
Copy link
Collaborator Author

gaearon commented Nov 23, 2017

I like this more: #11636

@gaearon
Copy link
Collaborator Author

gaearon commented Nov 23, 2017

Went with #11636 (comment)

@gaearon gaearon closed this Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants