1

我原来的问题出现在基于nuxt的项目中。为了解决这个问题,我通过 vue-cli 建立了一个新项目,并再次通过 npm 安装了 AVA,但它没有改变任何东西。我在 github 上发现了这个问题(https://github.com/nuxt/nuxt.js/issues/438),其中一条评论(Atinux,从 3 月 25 日开始)似乎回答了我的问题,但是当我尝试转到提到的链接我得到 404。问题作者说他永远不会想到使用完整路径,但我真的不明白他到底指的是什么地方。

我还尝试了几种不同的组件语法,但据我了解,问题出在 AVA 设置中,因为问题出在标记的第一个“<”符号中。当我不尝试导入我的组件并使用简单时,test.('test 2', t => t.pass())一切都很好并且测试通过了。我将非常感谢有关此问题的任何提示!

我的 HelloWorld.vue 文件:

    <template>
  <div class="hello">
    <h1>{{ msg }}</h1>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Vue app'
    }
  }
}
</script>

我的 HelloWorld.test.js 文件:

import test from 'ava'
import HelloWorld from './HelloWorld.vue'

test('message is Hello World', t => {
  t.is(HelloWorld.name, 'HelloWorld')
})

test('message is Hello World', t => {
  t.is(HelloWorld.$data.msg, 'Vue app')
})

我的 package.json 文件:

{
  "name": "ava-testing",
  "version": "1.0.0",
  "description": "lol",
  "author": "SP",
  "private": true,
  "scripts": {
    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
    "start": "npm run dev",
    "lint": "eslint --ext .js,.vue src",
    "build": "node build/build.js",
    "test": "ava"
  },
  "dependencies": {
    "vue": "^2.5.2"
  },
  "devDependencies": {
    "autoprefixer": "^7.1.2",
    "ava": "^0.24.0",
    "babel-core": "^6.22.1",
    "babel-eslint": "^7.1.1",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-loader": "^7.1.1",
    "babel-plugin-syntax-jsx": "^6.18.0",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-plugin-transform-vue-jsx": "^3.5.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.22.0",
    "chalk": "^2.0.1",
    "copy-webpack-plugin": "^4.0.1",
    "css-loader": "^0.28.0",
    "eslint": "^3.19.0",
    "eslint-config-standard": "^10.2.1",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-html": "^3.0.0",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-node": "^5.2.0",
    "eslint-plugin-promise": "^3.4.0",
    "eslint-plugin-standard": "^3.0.1",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^1.1.4",
    "friendly-errors-webpack-plugin": "^1.6.1",
    "html-webpack-plugin": "^2.30.1",
    "node-notifier": "^5.1.2",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "ora": "^1.2.0",
    "portfinder": "^1.0.13",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.8",
    "rimraf": "^2.6.0",
    "semver": "^5.3.0",
    "shelljs": "^0.7.6",
    "uglifyjs-webpack-plugin": "^1.1.1",
    "url-loader": "^0.5.8",
    "vue-loader": "^13.3.0",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.5.2",
    "webpack": "^3.6.0",
    "webpack-bundle-analyzer": "^2.9.0",
    "webpack-dev-server": "^2.9.1",
    "webpack-merge": "^4.1.0"
  },
  "engines": {
    "node": ">= 4.0.0",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}
4

1 回答 1

1

我在您的配置中看不到任何告诉测试进程如何加载.vue文件的内容。https://github.com/avajs/ava/blob/master/docs/recipes/vue.md应该有更多信息。

于 2017-12-24T12:09:56.743 回答