开玩笑-找不到测试

时间:2020-09-14 19:29:18

标签: node.js typescript unit-testing jestjs ts-jest

出于某种奇怪的原因,我无法进行开玩笑的测试。我在这里错过了什么吗?

我已经尝试了__test__和__tests __

文件夹结构

enter image description here

Package.json


  "scripts": {
    "start": "ts-node-dev --poll src/index.ts",
    "test": "jest watchAll --no-cache"
  },
  "jest": {
    "preset": "ts-jest",
    "testEnvironment": "node",
    "setupFilesAfterEnv": [
      "./src/test/setup.ts"
    ]
  },

错误

> auth@1.0.0 test E:\cultor-microservices\auth
> jest watchAll --no-cache

No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In E:\cultor-microservices\auth
  15 files checked.
  testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 1 match
  testPathIgnorePatterns: \\node_modules\\ - 15 matches
  testRegex:  - 0 matches
Pattern: watchAll - 0 matches

1 个答案:

答案 0 :(得分:1)

这是一个愚蠢的错误,我在测试脚本中忘记了watchAll前面的“-” package.json

  "scripts": {
    "start": "ts-node-dev --poll src/index.ts",
    "test": "jest --watchAll --no-cache"      // <-- here 
  }