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

Browser: Simple TypeScript test appearing+running in CLI mode but not Browser mode #3286

Closed
6 tasks done
frank-weindel opened this issue May 2, 2023 · 8 comments
Closed
6 tasks done
Labels
feat: browser Issues and PRs related to the browser runner

Comments

@frank-weindel
Copy link

frank-weindel commented May 2, 2023

Describe the bug

I have a simple TypeScript project with a single test file. The test file has only one test. When I run vitest in normal CLI mode the test is successfully run. When I run vitest --browser "chrome" the browser and vitest UI are launched but no tests are run.

Reproduction

https://github.com/frank-weindel/vitest-3286-browser-typescript

  • npm install
  • Run npm start to see example app working.
    • You should see "1 + 1 = 2" in browser
  • Run npm run test to see test for add() method running successfully
  • Run npm run test:browser to see Chrome browser + Vitest UI launching but no tests are run.

System Info

System:
    OS: macOS 12.2.1
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.14.0 - ~/.nodenv/versions/16.14.0/bin/node
    npm: 8.3.1 - ~/.nodenv/versions/16.14.0/bin/npm
  Browsers:
    Chrome: 112.0.5615.137

Used Package Manager

npm

Validations

@frank-weindel frank-weindel changed the title Browser: Simple TypeScript test appearing in CLI mode but not Browser mode Browser: Simple TypeScript test appaering/running in CLI mode but not Browser mode May 2, 2023
@frank-weindel frank-weindel changed the title Browser: Simple TypeScript test appaering/running in CLI mode but not Browser mode Browser: Simple TypeScript test appearing+running in CLI mode but not Browser mode May 2, 2023
@Aslemammad Aslemammad added bug feat: browser Issues and PRs related to the browser runner labels May 3, 2023
@tpluscode
Copy link

I think I have the same problem. The browser window opens but the network shows a hanging request for http://localhost:63315/@id/vitest/utils

@frank-weindel
Copy link
Author

frank-weindel commented May 3, 2023

@tpluscode I actually had that problem originally. But I found a workaround. See #3124 (comment).

@tpluscode
Copy link

Thanks!

@tpluscode
Copy link

Now the vitest UI loads but I get 504 Outdated Optimize Dep for the request for http://localhost:63315/@id/vitest/browser

@tpluscode
Copy link

tpluscode commented May 3, 2023

By experimenting blindly with the opimizeDeps options, I found that the 504 response is solved by setting noDiscovery: true

Then however, I sometimes get an error like:

SyntaxError: The requested module '/node_modules/concordance/index.js?v=ea45bb1f' does not provide an export named 'default'

@userquin
Copy link
Member

userquin commented May 3, 2023

Should be fixed in next 0.31.0 release, check optimizeDeps in #3190 (you need to remove .vite folder)

@abrowne2
Copy link

abrowne2 commented Jul 14, 2023

This is similar to my experience; removing the .vite folder does not seem to fix the issue either.

If I run vitest --ui my simple typescript tests are identified and pass, but if I run vitest --browser, with the same tests present, they show as No test suite found in file.

Using vitest 0.33.0

@sheremet-va sheremet-va removed the bug label Feb 16, 2024
@sheremet-va
Copy link
Member

This should be fixed now.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: browser Issues and PRs related to the browser runner
Projects
None yet
Development

No branches or pull requests

6 participants