-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add documentation for usage in testing #14
Comments
For └── public/
├── runtime-env.js
└── src/
├── setupTests.ts with this in // Because run-time environment variables are dynamically loaded by index.html,
// we need to manually load them into the test environment.
import '../public/runtime-env.js'; Regardless if you're using CRA, this general pattern applies to any usage of the Jest framework if you use the |
Much better! Best approach! Thanks for sharing!!! |
Hi, I was having issues with my jest tests (react framework is using CRA), and the
Jest automatically sets What should I do in this case? Runtime-env-cra doesn't work when NODE_ENV is set to test. |
@ZukkyBaig couldn't you just set the two different NODE_ENV's before running the two different scripts?
also, I break out the "env": "cross-env NODE_ENV=development runtime-env-cra --config-name ./public/runtime-env.js",
"test": "npm run env && cross-env NODE_ENV=test craco test --watchAll=false",
// OR
"pretest": "npm run env",
"test": "cross-env NODE_ENV=test craco test --watchAll=false", |
@seanblonien if you have time for it, can you add some docs about testing use cases? |
Hi! thanks again for the amazing library.
I was using it and I finded some problems to use in jest with react-testing-library.
To asegurate the app works well i'ts necesary add a property to a window object.
And to works well in any test I abstracted this to a function and added in before all in every test suite
The text was updated successfully, but these errors were encountered: