-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Ability to provide app css from a component #139
Comments
@stephenh Thank you for reaching us. Yes, of course, you can achieve your goal
Actually +import './global.scss';
+import '@your-design-system/css/dist/index.min.scss';
-jestPreviewConfigure({
- externalCss: [
- 'demo/global.scss',
- 'node_modules/@your-design-system/css/dist/index.min.scss',
- ],
-}); (I recommend turn on Automatic Mode on by default)
Yes, you can use this technique // src/test-utils/index.js
import { render } from "@testing-library/react";
// Render the whole app
const renderApp = () => {
return render(
<ApolloProvider client={apolloClient}>
<Router>
<CssBaseline />
<CssReset />
<App />
</Router>
</ApolloProvider>
);
};
export * from "@testing-library/react";
export { renderApp }; Then use import { debug } from 'jest-preview'
it('should behave correctly', () => {
renderApp();
// Do some stuff
debug()
}) You can read more about this technique here: https://testing-library.com/docs/react-testing-library/setup#custom-render Please let me know if my answer helps. Thanks. |
@nvh95 huh, I guess that is obvious in retrospect :-), but yeah, we already use a custom render approach, we just historically have not included our |
@stephenh Since Jest Preview trying to make Jest tests as "e2e" as possible. So I guess you need to setup it as a "completed" app from now on 😬. |
@stephenh Also, I wonder if your project is open source. I want to see it as a reference to add an example for emotion. If you want to contribute to Jest Preview by adding an example that uses emotion, please let me know. I can help to open a new issue to help you "claim" the feature. If you don't, it's absolutely OK, I will add one when I'm available. Thank you very much. |
Hey @nvh95 ; our primary app is not open source, but our emotion-based component library Beam is open source, so like here's an example of one of our tests: https://github.com/homebound-team/beam/blob/main/src/inputs/Checkbox.test.tsx Not sure if that's more helpful vs. just going through the Emotion setup docs, but if it helps, that's great. Our Beam component library also uses our emotion-based utility Css library, which has a much more minimal test suite if that's easier to copy/paste from: |
@stephenh It's super helpful. I will take a look in the morning my time. |
I just came across jest-preview and it's amazing! We use emotion and it's really sweet how great our components look with basically 2 minutes of work.
One thing that'd be great is the ability to provide our app-level CSS, which for us is still injected by emotion, but in our top
index.tsx
file, i.e.:The docs (which are great) have examples of adding root-/app-level
externalCss
frombootstap.min.css
files; is there a way to do this same sort ofexternalCss
but by pointingjest-preview
at a React component that includes ourCssBaseline
andCssReset
?Thanks!
The text was updated successfully, but these errors were encountered: