Как исправить эти ошибки, не импортируя некоторые модули в тестирование qarsar с помощью jest? - PullRequest
0 голосов
/ 25 мая 2019

Я пытаюсь реализовать тестирование моего квазар-проекта с помощью jest. Но у меня есть некоторые проблемы, чтобы не импортировать модули. Когда я запускаю тестовый проект, он не может импортировать модули. Как это исправить? Я новичок, поэтому, пожалуйста, расскажите об этом правильно и глубоко. Я очень благодарен, что помог мне исправить это.

Это мои ошибки.

    E:\workplace\unittesting\webboid\node_modules\@babel\runtime-corejs2\helpers\esm\asyncToGenerator.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import _Promise from "../../core-js/promise";
                                                                                                    ^^^^^^^^

    SyntaxError: Unexpected identifier

      17 |             q-icon.on-right(name="show_chart")
      18 |           q-btn( v-if="local" flat style="margin-right:10px;" @click="ipcRenderer.send('openURL','https://app.boid.com')")
    > 19 |             q-icon(name="home")
         |                                                 ^
      20 |           q-btn( v-else flat style="margin-right:10px;" @click="$router.push('/')")
      21 |             q-icon(name="home")
      22 |           q-btn.text-black(@click='' flat v-if="authenticated", color='light')

      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:471:17)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:513:25)
      at src/App.vue:19:49
      at Object.<anonymous> (src/App.vue:535:3)

Мой jest.config.js Файл следующий.

module.exports = {
  globals: {
    __DEV__: true,
  },
  verbose: false, // false since we want to see console.logs inside tests
  bail: false,
  testURL: 'http://localhost/',
  testEnvironment: 'jsdom',
  testRegex: './src/__unit__/.*.js$',
  rootDir: '.',
  testPathIgnorePatterns: [
    '<rootDir>/components/coverage/',
    '<rootDir>/test/cypress/',
    '<rootDir>/test/coverage/',
    '<rootDir>/dist/',
    '<rootDir>/node_modules/',
  ],
  moduleFileExtensions: ['js', 'json', 'vue'],
  moduleNameMapper: {
    '^vue$': 'vue/dist/vue.common.js',
    'quasar': 'quasar-framework/dist/umd/quasar.mat.umd.js',
  },
  resolver: null,
  transformIgnorePatterns: [
    'node_modules/core-js',
    'node_modules/babel-runtime',
    'node_modules/vue',
  ],
  transform: {
    '^.+\\.js$': '<rootDir>/node_modules/babel-jest',
    '.*\\.(vue)$': '<rootDir>/node_modules/vue-jest',
  }
}

Мой пакет.json следующий.

  "devDependencies": {
    "@babel/core": "^7.4.5",
    "@babel/plugin-proposal-class-properties": "^7.0.0",
    "@babel/plugin-proposal-decorators": "^7.0.0",
    "@babel/plugin-proposal-export-namespace-from": "^7.0.0",
    "@babel/plugin-proposal-function-sent": "^7.0.0",
    "@babel/plugin-proposal-json-strings": "^7.0.0",
    "@babel/plugin-proposal-numeric-separator": "^7.0.0",
    "@babel/plugin-proposal-throw-expressions": "^7.0.0",
    "@babel/plugin-syntax-dynamic-import": "^7.0.0",
    "@babel/plugin-syntax-import-meta": "^7.0.0",
    "@babel/plugin-transform-runtime": "^7.0.0",
    "@babel/preset-env": "^7.0.0",
    "autoprefixer": "^6.4.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "^24.8.0",
    "babel-loader": "^8.0.0",
    "babel-plugin-add-module-exports": "^1.0.0",
    "colors": "^1.1.2",
    "connect-history-api-fallback": "^1.1.0",
    "css-loader": "^0.28.7",
    "es6-promise": "^4.1.1",
    "eslint": "^4.8.0",
    "eslint-config-standard": "^10.2.1",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.9.0",
    "eslint-plugin-html": "^3.2.2",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-node": "^5.2.0",
    "eslint-plugin-promise": "^3.5.0",
    "eslint-plugin-standard": "^3.0.1",
    "eventsource-polyfill": "^0.9.6",
    "express": "^4.16.1",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^0.11.1",
    "friendly-errors-webpack-plugin": "^1.1.3",
    "glob": "^7.1.2",
    "html-webpack-plugin": "^2.30.1",
    "http-proxy-middleware": "^0.17.0",
    "jest": "^24.8.0",
    "json-loader": "^0.5.7",
    "opn": "^5.0.0",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "postcss-loader": "^1.0.0",
    "progress-bar-webpack-plugin": "^1.10.0",
    "purify-css": "^1.2.6",
    "shelljs": "^0.7.0",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.1",
    "url-loader": "^0.5.7",
    "vue-jest": "^3.0.4",
    "vue-loader": "^13.0.5",
    "vue-style-loader": "^3.0.3",
    "vue-template-compiler": "^2.5.0",
    "webpack": "^3.10.0",
    "webpack-bundle-analyzer": "^3.1.0",
    "webpack-dev-middleware": "^1.12.0",
    "webpack-hot-middleware": "^2.19.1",
    "webpack-merge": "^4.1.0"
...