vitevitest

Vitest CLI not recognized


installed pnpm add -D vitest and pnpm add -D @vitest/ui in my project dir, when i try vitest --ui, I get this error

vitest : The term 'vitest' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try 
again.

Solution

  • Ensure that your dependencies are installed by running pnpm install, and then try adding a new script to your package.json file for running your tests. For example:

      "scripts": {
        "dev": "vite",
        "build": "vite build",
        "test": "vitest --ui",
      },
    

    Enter the pnpm run test command in your terminal to run the script.