首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用jest & eslint在vue.js中定义describe()、it()和expect()?

如何使用jest & eslint在vue.js中定义describe()、it()和expect()?
EN

Stack Overflow用户
提问于 2021-12-30 18:01:06
回答 1查看 460关注 0票数 0

在这种情况下,如何定义describe()、it()和expect()?我得到了:No files found in C:\Users\tarek\Dogalu\dogalu_frontend_v2. Make sure Jest's configuration does not exclude this directory. To set up Jest, make sure a package.json file exists. Jest Documentation: facebook.github.io/jest/docs/configuration.html Files: "C:\Users\tarek\Dogalu\dogalu_frontend_v2\tests\unit\Gridcard.test.js"

[

这是我的Jest测试,但我只得到了未定义的函数。我几乎什么都试过了,包括npm安装-g eslint npm安装-g玩笑。

这是我的.eslintrc.js

代码语言:javascript
复制
module.exports = {
  root: true,
  env: {
    node: true
  },
  extends: [
    'plugin:vue/vue3-essential',
    '@vue/standard'
  ],
  parserOptions: {
    parser: 'babel-eslint'
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
  },
  overrides: [
    {
      files: [
        '**/__tests__/*.{j,t}s?(x)',
        '**/tests/unit/**/*.spec.{j,t}s?(x)'
      ],
      env: {
        jest: true
      }
    }
  ]

}

这是我的package.json

代码语言:javascript
复制
  "name": "dogalu_frontend_v2",
  "version": "0.1.0",
  "private": true,
  "engines": {
    "node": "16.x",
    "npm": "8.x"
  },
  "scripts": {
    "start": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "test:unit": "vue-cli-service test:unit",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "@pixi/filter-kawase-blur": "^4.1.5",
    "bootstrap": "^5.1.3",
    "bootstrap-icons": "^1.7.2",
    "boxicons": "^2.1.1",
    "core-js": "^3.6.5",
    "debounce": "^1.2.1",
    "hsl-to-hex": "^1.0.0",
    "pixi.js": "^6.2.0",
    "simplex-noise": "^3.0.0",
    "vue": "^3.0.0",
    "vue-router": "^4.0.0-0"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-plugin-unit-jest": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-standard": "^5.1.2",
    "@vue/test-utils": "^2.0.0-0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-import": "^2.20.2",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.0",
    "eslint-plugin-vue": "^7.0.0",
    "jest": "^25.5.4",
    "jest-fetch-mock": "^3.0.3",
    "supertest": "^6.1.6",
    "typescript": "~3.9.3",
    "vue-jest": "^5.0.0-0"
  }
}

那么,我如何定义describe()、it()和expect()呢?并预先感谢

EN

回答 1

Stack Overflow用户

发布于 2021-12-30 18:25:36

解决方案是将类命名为Gridcard.spec.js而不是Gridcard.test.js

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70535162

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档