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

docs: Need clearer description about triple slash command #1019

Closed
4 tasks done
alexzhang1030 opened this issue Mar 24, 2022 · 2 comments
Closed
4 tasks done

docs: Need clearer description about triple slash command #1019

alexzhang1030 opened this issue Mar 24, 2022 · 2 comments

Comments

@alexzhang1030
Copy link
Contributor

Clear and concise description of the problem

In the vitest documentation, i think we should clearer description about triple slash command,

👇 This is the description of aaa in the documentation

To configure vitest itself, add test property in your Vite config. You'll also need to add a reference to Vitest types using a triple slash command at the top of your config file, if you are importing defineConfig from vite itself.

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    // ...
  },
})

Suggested solution

should we update the doc to this ? 👇

To configure vitest itself, add test property in your Vite config. You'll also need to add a reference to Vitest types using a triple slash command at the top of your config file, if you are importing defineConfig from vite itself.

using defineConfig from vite you should follow this:

/// <reference types="vitest" />
import { defineConfig } from 'vite'

export default defineConfig({
  test: {
    // ...
  },
})

using defineConfig from vitest/config you should follow this:

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    // ...
  },
})

Alternative

No response

Additional context

No response

Validations

@meshantz
Copy link

meshantz commented Dec 9, 2022

I couldn't get this to work following the instructions as documented. The thing that was missing from my understanding was that 'vitest' needed to be imported for the reference to work. Could we add that into the docs as well?

ie:

import 'vitest'
/// <reference types="vitest" />
import { defineConfig } from 'vite'

@nmay231
Copy link

nmay231 commented Feb 18, 2023

@meshantz I had the exact same issue. I don't know what the problem was exactly, but I nuked my lock file and reinstalled and that did the trick.

rm yarn.lock
yarn install

Note: you can either 1) use the triple reference in your vite.config.ts (you don't need to import vitest), or 2) you can add "vitest/globals" to "types" in your tsconfig.json.

{
  "compilerOptions": {
    "types": ["vitest/globals"]
  }
}

It might have been because I had multiple versions of vite installed unintentionally (try running yarn why vite. It said I had 4.1.2 and 4.0.4 installed), but it might have been some other random reason.

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

No branches or pull requests

4 participants