aboutsummaryrefslogtreecommitdiff
path: root/integration/snippets/styledcomponents-output.js
diff options
context:
space:
mode:
Diffstat (limited to 'integration/snippets/styledcomponents-output.js')
-rw-r--r--integration/snippets/styledcomponents-output.js48
1 files changed, 26 insertions, 22 deletions
diff --git a/integration/snippets/styledcomponents-output.js b/integration/snippets/styledcomponents-output.js
index 16ac1ed6b..a79b5e24d 100644
--- a/integration/snippets/styledcomponents-output.js
+++ b/integration/snippets/styledcomponents-output.js
@@ -32,28 +32,32 @@ const ErrorScreenRoot = styled.div`
`;
export function test() {
- const reactEl = document.createElement("div");
- document.body.appendChild(reactEl);
- ReactDOM.render(
- <ErrorScreenRoot id="error-el">
- The react child should have this text
- </ErrorScreenRoot>,
- reactEl
- );
+ if (typeof window !== "undefined") {
+ const reactEl = document.createElement("div");
+ document.body.appendChild(reactEl);
+ ReactDOM.render(
+ <ErrorScreenRoot id="error-el">
+ The react child should have this text
+ </ErrorScreenRoot>,
+ reactEl
+ );
- const style = document.querySelector("style[data-styled]");
- console.assert(style, "style tag should exist");
- console.assert(
- style.textContent.split("").every((a) => a.codePointAt(0) < 128),
- "style tag should not contain invalid unicode codepoints"
- );
- console.assert(
- document.querySelector("#error-el").textContent ===
- "The react child should have this text"
- );
+ const style = document.querySelector("style[data-styled]");
+ console.assert(style, "style tag should exist");
+ console.assert(
+ style.textContent.split("").every((a) => a.codePointAt(0) < 128),
+ "style tag should not contain invalid unicode codepoints"
+ );
+ console.assert(
+ document.querySelector("#error-el").textContent ===
+ "The react child should have this text"
+ );
- ReactDOM.unmountComponentAtNode(reactEl);
- reactEl.remove();
- style.remove();
- testDone(import.meta.url);
+ ReactDOM.unmountComponentAtNode(reactEl);
+ reactEl.remove();
+ style.remove();
+ return testDone(import.meta.url);
+ }
+
+ return testDone(import.meta.url);
}