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
I am trying to test my wrapper and I get the following warning:
Warning: An update to ReactAsyncHighlighter inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
Here is the test:
import { render } from "@testing-library/react";
import { PrismAsyncLight as SyntaxHighlighter } from "react-syntax-highlighter";
// languages
import js from "react-syntax-highlighter/dist/esm/languages/prism/javascript";
// themes
import themeLight from "react-syntax-highlighter/dist/esm/styles/prism/one-light";
SyntaxHighlighter.registerLanguage("javascript", js);
describe("CodeHighlight", () => {
it("should render successfully", () => {
const code = `const a = "test"`;
render(
<SyntaxHighlighter language={"javascript"} style={themeLight} showLineNumbers={false}>
{code}
</SyntaxHighlighter>
);
});
});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I am trying to test my wrapper and I get the following warning:
Here is the test:
Any idea? :/
Beta Was this translation helpful? Give feedback.
All reactions