Home > database >  VueJS Unit testing - I cannot run my tests. "Command 'test/unit' does not exists"
VueJS Unit testing - I cannot run my tests. "Command 'test/unit' does not exists"

Time:05-02

I'm trying to setup Unit Tests with VueJS 3. Reading the docs of Vue 3, I Installed test-utils 2.0

My package.json file looks like this :

{
  "name": "testsUnitVue",
  "version": "0.1.0",
  "private": true,
  "scripts": {

    ...

    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "test:unit": "vue-cli-service test:unit",
    "lint": "vue-cli-service lint",

    ...

  },
  "dependencies": {
    ...
  },
  "devDependencies": {

    ...

    "@vue/test-utils": "^2.0.0-rc.21",

    ...

  }
}

I try to run my the tests with:

npm run test:unit

But I've the following error message:

> [email protected] test:unit
> vue-cli-service test:unit

 ERROR  command "test:unit" does not exist.

I've a similar result with yarn command. How can I solve this?

PS: If you need more informations, then just leave a comment :)

CodePudding user response:

The @vue/test-utils does not provide the unit:test subcommand of vue-cli-service. Those are available when using one of the following plugins:

For instructions on how to install those see: https://cli.vuejs.org/guide/plugins-and-presets.html#installing-plugins-in-an-existing-project

  • Related