You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.
When I need to test components that have react-intl components, I want to be able to wrap the JSX with wrapIntl(<SampleComponent />) without importing the code above in every file.
The text was updated successfully, but these errors were encountered:
Would you mind explaining what exactly is the problem with importing that helper function in the files you use it? Suppose that's what modules are for, aren't they?
That said - strictly speaking, you can do that, I just wouldn't recommend it.
In the test setup file, you're allowed to modify the global window object, i.e. you might attach your function to it. But again, that's not recommended - you should just import it from the module whereever needed. You won't even hit any reasonable performance gap by doing so.
Is it possible to write a function in the
src/setupTest.ts
file that will be available in every test file?For example, I want to write a
react-intl
helper that I can use when testing components. I have the following code:The
createIntlWrapper
returns a function which mimic this helper function.When I need to test components that have react-intl components, I want to be able to wrap the JSX with
wrapIntl(<SampleComponent />)
without importing the code above in every file.The text was updated successfully, but these errors were encountered: