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

happy dom environmentoptions in vite.config.ts don't work #4040

Closed
6 tasks done
Fallsleep opened this issue Aug 29, 2023 · 4 comments
Closed
6 tasks done

happy dom environmentoptions in vite.config.ts don't work #4040

Fallsleep opened this issue Aug 29, 2023 · 4 comments

Comments

@Fallsleep
Copy link

Fallsleep commented Aug 29, 2023

Describe the bug

since #3972 fixed pass environmentOptions to happy-dom integration, set url by adding annotation before test file works well, but set url by environmentoptions in vite.config.ts file still has no effect.

It cause window.location.href to be the default http://localhost:3000/, and document.cookie is empty even cookie was setting by msw

Reproduction

https://stackblitz.com/edit/vitest-happy-dom-environmentoptions-test?file=test%2Fglobal.test.ts

global.test.ts failed, annotation.test.ts passed.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
    Memory: 3.18 GB / 15.92 GB
  Binaries:
    Node: 16.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - D:\nodejs\node_global\yarn.CMD
    npm: 8.15.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 116.0.5845.97
    Edge: Spartan (44.19041.1266.0), Chromium (116.0.1938.62)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @vitejs/plugin-legacy: ^2.1.0 => 2.1.0
    @vitejs/plugin-vue: ^3.1.0 => 3.1.0
    @vitejs/plugin-vue-jsx: ^2.0.1 => 2.0.1
    @vitest/coverage-v8: ^0.34.3 => 0.34.3
    @vitest/ui: ^0.34.3 => 0.34.3
    vite: ^3.1.0 => 3.1.0
    vitest: ^0.34.3 => 0.34.3

Used Package Manager

yarn

Validations

@stackblitz
Copy link

stackblitz bot commented Aug 29, 2023

@sheremet-va
Copy link
Member

It should be happyDom in the config, but even then it didn't work for me.

@Dunqing
Copy link
Member

Dunqing commented Sep 5, 2023

It should be happyDom in the config, but even then it didn't work for me.

Should it be happyDOM? I tested it with happyDOM and all test cases passed

async setupVM({ happyDOM = {} }) {

@sheremet-va
Copy link
Member

Should it be happyDOM? I tested it with happyDOM and all test cases passed

Yes, sorry. JS name is consistent with how happyDOM names it in its js API

@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants