mercredi 2 décembre 2020

Vue Unit Testing with Jest - Unexpected Token Export

i'm trying to test my vue app with jest and vue test utils. ive installed it according to the documentation but when running a test it throws this error:

H:\dev\app\vue\node_modules\vuetify\lib\index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export * from './components';
                                                                                         ^^^^^^

SyntaxError: Unexpected token 'export'

  at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
  at node_modules/tiptap-vuetify/dist/bundle-umd.js:1:201
  at Object.<anonymous> (node_modules/tiptap-vuetify/dist/bundle-umd.js:1:429)

my package.json

   {
  "name": "journal",
  "version": "0.1.0",
  "homepage": "./",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "buildDev": "vue-cli-service build --mode development",
    "lint": "vue-cli-service lint",
    "test": "jest"
  },
  "dependencies": {
    "core-js": "^3.8.0",
    "jest": "^26.6.3",
    "tiptap-vuetify": "^2.24.0",
    "vue": "^2.6.12",
    "vue-resizable": "^1.2.5",
    "vue-resource": "^1.5.1",
    "vuetify": "^2.3.19"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/preset-env": "^7.12.7",
    "@vue/cli-plugin-babel": "~4.3.0",
    "@vue/cli-plugin-eslint": "~4.3.0",
    "@vue/cli-service": "~4.3.0",
    "@vue/eslint-config-standard": "^5.1.2",
    "@vue/test-utils": "^1.1.1",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^10.1.0",
    "babel-jest": "^26.6.3",
    "eslint": "^6.7.2",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.1.0",
    "eslint-plugin-vue": "^6.2.2",
    "less": "^3.12.2",
    "less-loader": "^5.0.0",
    "sass": "^1.29.0",
    "sass-loader": "^8.0.0",
    "vue-cli-plugin-vuetify": "^2.0.7",
    "vue-jest": "^3.0.7",
    "vue-template-compiler": "^2.6.12",
    "vuetify-loader": "^1.6.0"
  },
  "babel": {
    "presets": [
      "@babel/preset-env"
    ]
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "browser": true,
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "@vue/standard"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

my jest.config.js

module.exports = {
  moduleFileExtensions: [
    'vue',
    'json',
    'js'
  ],
  transform: {
    '^[^.]+.vue$': 'vue-jest',
    '.*\\.(js)$': 'babel-jest'
  }
}

and my babel.config.js

    module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset',
    '@babel/preset-env'
  ]
}

Already tried a few different things ive come across, but none seem to work. reinstalled the entire project twice. not sure whats happening

Aucun commentaire:

Enregistrer un commentaire