Skip to content

Commit 9992f14

Browse files
committed
fix: window dependency fixed
1 parent ca34271 commit 9992f14

File tree

3 files changed

+943
-463
lines changed

3 files changed

+943
-463
lines changed

helpers/all.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,12 @@ export function renderSpec(asyncapi, params) {
159159
const config = prepareConfiguration(params);
160160
const stringified = stringifySpec(asyncapi);
161161
const component = <AsyncApiComponent schema={stringified} config={config}/>;
162+
if (typeof global.window === 'undefined' || !global.window.document) {
163+
const { JSDOM } = require('jsdom');
164+
const jsdomInstance = new JSDOM('<!doctype html><html><body></body></html>');
165+
global.window = jsdomInstance.window;
166+
global.document = jsdomInstance.window.document;
167+
}
168+
162169
return ReactDOMServer.renderToString(component);
163170
}

0 commit comments

Comments
 (0)