-
Notifications
You must be signed in to change notification settings - Fork 188
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
Error in test: Cannot automatically buffer without a document #23
Comments
Seems like a problem with your testing environment. The error says there is no If you are trying to test how your components will render in a browser environment, there are many tools out there that will run your tests in browser. Two examples are karma and browser-run. If you are trying to test how your components will render on the server, then you will need to do something more along the lines of this in your tests: import {renderToString} from 'react-dom/server'
import {StyleSheetServer} from 'aphrodite'
const {html, css} = StyleSheetServer.renderStatic(() => renderToString(<Dummy {...props} />)) as explained here. Hope that helps! |
Aphrodite won't work without a browser environment. It tries to automatically inject styles into the document, which doesn't work without some setup. I'm not sure what your You can also use something like |
@xymostech @montemishkin Thanks guys, indeed, I am using just mocha testing and didn't realize that Aphrodite requires a DOM to render out the styles (that's my current understanding). Appreciate the suggestion to use StyleSheetServer.renderStatic. |
Hi there, I was testing a simple stateless functional component while encountered this. Here's my component and the test code:
And the test:
And finally the error:
Any one can shed some light on this?
Thank you!
The text was updated successfully, but these errors were encountered: