Skip to content

Handing code that uses document.createElement('script') #1482

Answered by is-jonreeves
is-jonreeves asked this question in Q&A
Discussion options

You must be logged in to vote

I was reading through this page, and tried the following options and it seems to have silenced the errors.

window.happyDOM.settings.disableJavaScriptFileLoading = true;
window.happyDOM.settings.handleDisabledFileLoadingAsSuccess = true

I'm not sure if its the appropriate way to do it, but here is how I've implemented it in the test suite:

beforeAll(() => {
  // see https://github.com/capricorn86/happy-dom/wiki/IOptionalBrowserSettings
  vi.stubGlobal('happyDOM', merge(('happyDOM' in global) ? global.happyDOM : {}, { settings: { disableJavaScriptFileLoading: true, handleDisabledFileLoadingAsSuccess: true } }));
});

afterAll(() => {
  vi.unstubAllGlobals();
});

I will go with it for now, …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by is-jonreeves
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant