-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: pass environmentOptions to happy-dom integration #3902
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
/** | ||
* @vitest-environment happy-dom | ||
* @vitest-environment-options { "settings": { "disableCSSFileLoading": true }, "width": 1920 } | ||
*/ | ||
|
||
/* eslint-disable vars-on-top */ | ||
|
@@ -11,8 +12,19 @@ import { expect, it, vi } from 'vitest' | |
declare global { | ||
// eslint-disable-next-line no-var | ||
var __property_dom: unknown | ||
// eslint-disable-next-line no-var | ||
var happyDOM: unknown | ||
} | ||
|
||
it('defaults URL to localhost:3000', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same applies here. I'd like to try passing and not passing URL, but no idea how to do that using JSDoc comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can create a separate test file |
||
expect(location.href).toBe('http://localhost:3000/') | ||
}) | ||
|
||
it('accepts custom environment options', () => { | ||
// default is false | ||
expect((window.happyDOM as any).settings.disableCSSFileLoading).toBe(true) | ||
}) | ||
Comment on lines
+23
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we leverage on passing envrionment options via JSDoc code block, I didn't find a way where I could test passing the option vs not passing. |
||
|
||
it('defined on self/window are defined on global', () => { | ||
expect(self).toBeDefined() | ||
expect(window).toBeDefined() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think naming it
happyDOM
in the config is fineThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The types can be found here:
The source code for them is here:
https://github.com/capricorn86/happy-dom/blob/master/packages/happy-dom/src/window/IHappyDOMOptions.ts