Skip to content

Commit d270b8e

Browse files
Remove Jest globals from utils
1 parent a5cacf9 commit d270b8e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/util/components/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export async function renderServer(element: JSX.Element, options: RenderOptions
2222

2323
// Find rendered modules
2424
const modules = [...container.querySelectorAll<HTMLElement>(selector)];
25-
expect(modules.length).toBeGreaterThan(0);
25+
if (!modules.length) {
26+
throw new Error(`renderServer: No modules found: ${selector}`);
27+
}
2628

2729
return { container, element, modules };
2830
}
@@ -39,13 +41,13 @@ export async function renderClient(element: JSX.Element, options: RenderOptions
3941

4042
// Find rendered modules
4143
const modules = [...container.querySelectorAll<HTMLElement>(selector)];
42-
expect(modules.length).toBeGreaterThan(0);
44+
if (!modules.length) {
45+
throw new Error(`renderClient: No modules found: ${selector}`);
46+
}
4347

4448
// Verify module initialisation
45-
if (moduleName) {
46-
for (const $root of modules) {
47-
expect($root).toHaveAttribute(`data-${moduleName}-init`);
48-
}
49+
if (moduleName && !modules.every(($root) => $root.hasAttribute(`data-${moduleName}-init`))) {
50+
throw new Error(`renderClient: Not all modules are initialised: ${selector}`);
4951
}
5052

5153
return { container, element, modules };

0 commit comments

Comments
 (0)