Handing code that uses document.createElement('script') #1482
|
I'm using I have a react hook that uses I noticed this topic so tried I also tried mocking fetch in What is the best way to handle the scenario where I need to place a script tag but don't want to make the actual network call? |
Replies: 2 comments
|
I was reading through this page, and tried the following options and it seems to have silenced the errors. 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, but let me know if I should be doing something else |
|
@is-jonreeves it is now also possible to intercept requests and return with a mocked response: |
I was reading through this page, and tried the following options and it seems to have silenced the errors.
I'm not sure if its the appropriate way to do it, but here is how I've implemented it in the test suite:
I will go with it for now, …