MounirOnGithub
MounirOnGithub

Reputation: 699

Module @vue/cli-plugin-unit-jest should have "jest-preset.js" or "jest-preset.json" file at the root

I've set up my project in a project containing only folder with icons inside with the following commande vue create .

I've selected Jest for testing and done nothing more When I run npm run test:unit I have the following output

● Validation Error:

  Module @vue/cli-plugin-unit-jest should have "jest-preset.js" or "jest-preset.json" file at the root.

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

Anyone ?

Upvotes: 1

Views: 1750

Answers (2)

Jaredcheeda
Jaredcheeda

Reputation: 2014

Replace this:

  preset: '@vue/cli-plugin-unit-jest',

with this:

  moduleFileExtensions: [
    'js',
    'json',
    'vue'
  ],
  transform: {
    '^.+\\.vue$': 'vue-jest',
    '.+\\.(css|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
    '^.+\\.js?$': 'babel-jest'
  },

Then run:

  • npm install --save-dev vue-jest jest-transform-stub [email protected]
  • npm uninstall @vue/cli-plugin-unit-jest

Upvotes: 0

Saurav Singh
Saurav Singh

Reputation: 11

Hi even I was facing the same issue.

I just updated the @vue/cli-plugin-unit-jest package and it worked for me.

My Vue version is 2.6.11

and I updated @vue/cli-plugin-unit-jest to @4.5.0

npm -i -s @vue/[email protected]

Upvotes: 1

Related Questions