Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

raulfdm
Copy link
Contributor

@raulfdm raulfdm commented Aug 7, 2023

Description

This PR forwards the environmentOptions to happy-dom integration.

It follows the same principle defined in the jsdom integration

async setupVM({ jsdom = {} }) {

Reference: https://github.com/capricorn86/happy-dom/wiki/Getting-started#usage

Closes #3903
Closes #3905

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@stackblitz
Copy link

stackblitz bot commented Aug 7, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify
Copy link

netlify bot commented Aug 7, 2023

Deploy Preview for fastidious-cascaron-4ded94 ready!

Name Link
🔨 Latest commit 54866e1
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/64d9c92180e3600007d15114
😎 Deploy Preview https://deploy-preview-3902--fastidious-cascaron-4ded94.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@capricorn86
Copy link
Contributor

I have closed #3907 now as this PR has added the default URL to it.

@raulfdm raulfdm requested a review from userquin August 13, 2023 07:46
@userquin
Copy link
Member

We should add a test

@raulfdm
Copy link
Contributor Author

raulfdm commented Aug 14, 2023

We should add a test

@userquin I've added them. Let me know if it's enough

Comment on lines +23 to +26
it('accepts custom environment options', () => {
// default is false
expect((window.happyDOM as any).settings.disableCSSFileLoading).toBe(true)
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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('defaults URL to localhost:3000', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can create a separate test file

@raulfdm raulfdm requested a review from userquin August 14, 2023 06:29
Copy link
Member

@sheremet-va sheremet-va left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, can you add types to environmentOptions in the config?

@@ -5,9 +5,12 @@ import { populateGlobal } from './utils'
export default <Environment>({
name: 'happy-dom',
transformMode: 'web',
async setupVM() {
async setupVM({ 'happy-dom': happyDom = {} }) {
Copy link
Member

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 fine

Copy link
Contributor

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:

     import IHappyDOMOptions from 'happy-dom/lib/window/IHappyDOMOptions.js';

The source code for them is here:
https://github.com/capricorn86/happy-dom/blob/master/packages/happy-dom/src/window/IHappyDOMOptions.ts

}

it('defaults URL to localhost:3000', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can create a separate test file

@sheremet-va sheremet-va added this to the 0.34.2 milestone Aug 15, 2023
@sheremet-va
Copy link
Member

I'm going to do a release in a few minutes, but you didn't allow maintainers to push to your PR, so I created a separate one: #3972

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default URL when using Happy DOM as environment happy-dom integration does not uses environmentOptions
4 participants