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(vitest): headless mode not working when using webdriverio (fix #3930) #3996

Closed

Conversation

LorenzoBloedow
Copy link
Contributor

I skimmed through the v6, v7, and v8 docs for webdriverio but I didn't really find any documentation for the wdio:devtoolsOptions key on the current code causing this issue:

capabilities: {
  'browserName': this.browser,
  'wdio:devtoolsOptions': { headless: options.headless },
},

IMPORTANT:
I couldn't reproduce this issue, I realize this was my mistake and I should've tried that before starting to write the code.
I have a suggestion regarding reproductions (let me know if I should open a discussion for this): they should be made mandatory and the issue should be automatically (and/or manually) closed until a repro that actually works is provided, otherwise false-positives made by user error may become very common, but that's just my take on it, let me know what you think!

This fixes #3930 (if it's confirmed to be an issue)

@stackblitz
Copy link

stackblitz bot commented Aug 21, 2023

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

@netlify
Copy link

netlify bot commented Aug 21, 2023

Deploy Preview for fastidious-cascaron-4ded94 ready!

Name Link
🔨 Latest commit fb021d4
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/6516239db04d9d0007edc7c5
😎 Deploy Preview https://deploy-preview-3996--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.

@sheremet-va
Copy link
Member

Please, don't remove PR checklist when creating PR. One of the points there is to not push pnpm-lockfile changes.

@LorenzoBloedow
Copy link
Contributor Author

Please, don't remove PR checklist when creating PR. One of the points there is to not push pnpm-lockfile changes.

Sorry, I should've read it.
I've removed pnpm-lockfile.yaml now

@LorenzoBloedow
Copy link
Contributor Author

Please, don't remove PR checklist when creating PR. One of the points there is to not push pnpm-lockfile changes.

Sorry, I should've read it.
I've removed pnpm-lockfile.yaml now

Just noticed I mistakenly ran git rm instead of checking out to the unchanged file 🤦

I'll revert this soon

@sheremet-va
Copy link
Member

I just noticed that remote accepts "headless" option. Can't we just pass it down?

@LorenzoBloedow
Copy link
Contributor Author

I just noticed that remote accepts "headless" option. Can't we just pass it down?

webdriverio doesn't seem to have complete documentation for the options for remote on their website.
But I inspected the declaration file with the headless option and this is what I found:

/**
* Sauce Labs provides a headless offering that allows you to run Chrome and Firefox tests headless.
*/
headless?: boolean;

I thought it was weird so I decided to test it myself, and yeah I can confirm it doesn't work (at least without Sauce Labs)

@sheremet-va
Copy link
Member

I thought it was weird so I decided to test it myself, and yeah I can confirm it doesn't work (at least without Sauce Labs)

Ok, no problem 👍🏻

@LorenzoBloedow
Copy link
Contributor Author

@sheremet-va I'm not sure how to proceed since we're getting the ERR_PNPM_OUTDATED_LOCKFILE error on CI and I'm not supposed to upload the lock file.

@sheremet-va
Copy link
Member

@sheremet-va I'm not sure how to proceed since we're getting the ERR_PNPM_OUTDATED_LOCKFILE error on CI and I'm not supposed to upload the lock file.

Sorry, since you added a new package, you can update the lockfile. But make sure it only includes the new package there (example of good lockfile update in #4027).

@sheremet-va
Copy link
Member

Looks like it's still broken

@LorenzoBloedow
Copy link
Contributor Author

Looks like it's still broken

I'm having some trouble trying to update only @wdio/types.
I tried using many different command and version combinations including pnpm add --filter ./vitest --prefer-offline --lockfile-only @wdio/types (cwd: vitest/packages) but I always get a lot of unrelated packages updated as well (like /@babel/helper-create-class-features-plugin@7.22.11(@babel/core@7.22.11).

I also found a recent issue from someone with the same problem as me.

@sheremet-va
Copy link
Member

Looks like it's still broken

I'm having some trouble trying to update only @wdio/types.

I tried using many different command and version combinations including pnpm add --filter ./vitest --prefer-offline --lockfile-only @wdio/types (cwd: vitest/packages) but I always get a lot of unrelated packages updated as well (like /@babel/helper-create-class-features-plugin@7.22.11(@babel/core@7.22.11).

I also found a recent issue from someone with the same problem as me.

The jus updating it should be fine I think

@LorenzoBloedow
Copy link
Contributor Author

The jus updating it should be fine I think

Not sure what you meant but I'm assuming you asked me to just run the previous install command and commit so that's what I did (it does look like there are some unrelated packages being updated in the lockfile though)

pnpm-lock.yaml Outdated Show resolved Hide resolved
@LorenzoBloedow
Copy link
Contributor Author

Fixed the types and ran all CI commands on my machine, not sure why test:ci threw in the last run though, works fine here.

@sheremet-va
Copy link
Member

I don't understand why your CI fails when main doesn't 🤔

@LorenzoBloedow
Copy link
Contributor Author

I don't understand why your CI fails when main doesn't 🤔

The errors are weird because they don't seem to have much to do with what I think caused it, but basically I didn't need to add some mapping keys in the lockfile because they were already there.

I thought pnpm install would fail when that happens but apparently not.
It should be fixed now since I ran the github actions locally with act before and after and the problem seems to be fixed.

@sheremet-va
Copy link
Member

Browser tests fail now 😄 (Because of the changes here looks like)

@LorenzoBloedow
Copy link
Contributor Author

Browser tests fail now 😄 (Because of the changes here looks like)

This PR is making me feel silly lol.
I tried to fix it but unfortunately I don't have a Mac and it's failing because of Safari so I can't confirm my changes locally.
It seems like a pretty simple fix though, let's just hope the next CI run is finally the last one! :)

@LorenzoBloedow
Copy link
Contributor Author

This is weird... I ran the failed CI commands on Windows and they all passed, the lockfile looks fine, and everything else hasn't
changed. Not sure how to proceed here, could this possibly be a problem with the CI cache?

frodeaa added a commit to Dintero/Dintero.Checkout.Web.SDK that referenced this pull request Oct 7, 2023
Replace karma, chai, mocha, puppeteer, and sinon with vitest,
@vitest/browser and webdriverio

Remove `^` from all dependencies and update their version to the locked
version

`@vitest/browser` is an experimental package with some "bugs" so a patch to fix
headless flag and add support for custom browser binary was needed in order to run
the test in Github Actions

Closes: #250
Closes: #180
Rel: https://github.com/karma-runner/karma#karma-is-deprecated-and-is-not-accepting-new-features-or-general-bug-fixes
Rel: https://vitest.dev/guide/
Rel: vitest-dev/vitest#3996
frodeaa added a commit to Dintero/Dintero.Checkout.Web.SDK that referenced this pull request Oct 9, 2023
Replace karma, chai, mocha, puppeteer, and sinon with vitest,
@vitest/browser and webdriverio

Remove `^` from all dependencies and update their version to the locked
version

`@vitest/browser` is an experimental package with some "bugs" so a patch to fix
headless flag and add support for custom browser binary was needed in order to run
the test in Github Actions

Closes: #250
Closes: #180
Rel: https://github.com/karma-runner/karma#karma-is-deprecated-and-is-not-accepting-new-features-or-general-bug-fixes
Rel: https://vitest.dev/guide/
Rel: vitest-dev/vitest#3996
webdriverBrowserExtensionMap[this.browser].value.args.push('-headless')
break
case 'edge':
webdriverBrowserExtensionMap[this.browser].value.args.push('--headless')
Copy link
Member

@userquin userquin Oct 13, 2023

Choose a reason for hiding this comment

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

we can use same configuration for chrome

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.

Headless mode is not working for WebDriverIO
4 participants