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

React is not defined #77

Closed
juanruben opened this issue Aug 22, 2022 · 3 comments
Closed

React is not defined #77

juanruben opened this issue Aug 22, 2022 · 3 comments
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@juanruben
Copy link

juanruben commented Aug 22, 2022

Describe the bug
In a very simple test for a component I keep getting React is not defined

To Reproduce
Run test in the UI for a component

Expected behavior
Run test successfully. The plugin works ok with non react tests. The react tests run without any issue in the console.

Screenshots
Screen Shot 2022-08-22 at 7 14 46 PM

Environment

  • OS: macOS
  • VSCode version: 1.70.2
  • Vitest version: 0.22.1
  • Vitest plugin version: 0.2.24
@juanruben juanruben added the p3-minor-bug An edge case that only affects very specific usage (priority) label Aug 22, 2022
@Pustinyak
Copy link

Probably related to #13, but with my example it'll work fine until monorepo is supported.

If you have a monorepo, the command should be started with the help of your package manager. Here is an example with npm:

"vitest.commandLine": "npm -w @monorepo/package-name test --"

Put this line in .vscode/settings.json and it should work. Can't give yarn/pnpm examples but it's the same for all.

Also the package's package.json should contain the script you are calling, in this case is test:

"scripts": {
    "test": "vitest",
}

@gaokun
Copy link

gaokun commented Sep 20, 2022

Probably related to #13, but with my example it'll work fine until monorepo is supported.

If you have a monorepo, the command should be started with the help of your package manager. Here is an example with npm:

"vitest.commandLine": "npm -w @monorepo/package-name test --"

Put this line in .vscode/settings.json and it should work. Can't give yarn/pnpm examples but it's the same for all.

Also the package's package.json should contain the script you are calling, in this case is test:

"scripts": {
    "test": "vitest",
}

@Pustinyak Thanks for the solution, I changed it a little bit for yarn, and works fine in one monorepo

"vitest.commandLine": "yarn workspace @monorepo/package-a test --watch" 

but I also have a package-b in this monorepo, vitest.commandLine is specific with package-a already,
I tried, it failed in package-b.

If you have any idea about this, please.
Thanks in advance.
Ken

@zxch3n
Copy link
Member

zxch3n commented Feb 8, 2023

You can try using the vscode workspace to open folders that require different configs. Each folder can have its own .vscode settings.

@zxch3n zxch3n closed this as completed Feb 8, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

No branches or pull requests

4 participants