mac 的 Timemachine 之前不管有没有 jest.config.js 总是 No files found

mac 的 Timemachine 之前不管有没有 jest.config.js 总是 No files found

答案1

自定义--runTestsByPath unit-test/**.jscli选项,试一下,成功

macBook-2:~/code/jest-demo (master)
chris$ npm run test

> [email protected] test /Users/chris/code/jest-demo
> jest --runTestsByPath unit-test/**.js

 PASS  unit-test/everyDataType.test.js
 PASS  unit-test/callback.test.js
 PASS  unit-test/async-await.test.js
 PASS  unit-test/mock.test.js
 PASS  unit-test/json.test.js
 PASS  unit-test/promise.test.js

Test Suites: 6 passed, 6 total
Tests:       3 skipped, 17 passed, 20 total
Snapshots:   0 total
Time:        3.386s
Ran all test suites within paths "unit-test/async-await.test.js", "unit-test/callback.test.js", "unit-test/everyDataType.test.js", "unit-test/json.test.js", "unit-test/mock.test.js", "unit-test/promise.test.js".

调试

{
  "configs": [
    {
      "automock": false,
      "browser": false,
      "cache": true,
      "cacheDirectory": "/private/var/folders/6q/6ll3np5j1ybf17dk3bs1lk0r0000gn/T/jest_dx",
      "clearMocks": false,
      "coveragePathIgnorePatterns": [
        "/node_modules/"
      ],
      "cwd": "/Users/chris/code/jest-demo",
      "dependencyExtractor": null,
      "detectLeaks": false,
      "detectOpenHandles": false,
      "errorOnDeprecated": false,
      "filter": null,
      "forceCoverageMatch": [],
      "globalSetup": null,
      "globalTeardown": null,
      "globals": {},
      "haste": {
        "computeSha1": false,
        "providesModuleNodeModules": [],
        "throwOnModuleCollision": false
      },
      "moduleDirectories": [
        "node_modules"
      ],
      "moduleFileExtensions": [
        "js",
        "json",
        "jsx",
        "ts",
        "tsx",
        "node"
      ],
      "moduleNameMapper": {},
      "modulePathIgnorePatterns": [],
      "name": "bfdbd0febd5d8ac8761eaad7d35f82fc",
      "prettierPath": "prettier",
      "resetMocks": false,
      "resetModules": false,
      "resolver": null,
      "restoreMocks": false,
      "rootDir": "/Users/chris/code/jest-demo",
      "roots": [
        "/Users/chris/code/jest-demo"
      ],
      "runner": "jest-runner",
      "setupFiles": [],
      "setupFilesAfterEnv": [],
      "skipFilter": false,
      "snapshotSerializers": [],
      "testEnvironment": "/Users/chris/code/jest-demo/node_modules/jest-environment-jsdom/build/index.js",
      "testEnvironmentOptions": {},
      "testLocationInResults": false,
      "testMatch": [
        "**/__tests__/**/*.[jt]s?(x)",
        "**/?(*.)+(spec|test).[tj]s?(x)"
      ],
      "testPathIgnorePatterns": [
        "/node_modules/"
      ],
      "testRegex": [],
      "testRunner": "/Users/chris/code/jest-demo/node_modules/jest-jasmine2/build/index.js",
      "testURL": "http://localhost",
      "timers": "real",
      "transform": [
        [
          "^.+\\.[jt]sx?$",
          "/Users/chris/code/jest-demo/node_modules/babel-jest/build/index.js"
        ]
      ],
      "transformIgnorePatterns": [
        "/node_modules/"
      ],
      "watchPathIgnorePatterns": []
    }
  ],
  "globalConfig": {
    "bail": 0,
    "changedFilesWithAncestor": false,
    "collectCoverage": false,
    "collectCoverageFrom": null,
    "coverageDirectory": "/Users/chris/code/jest-demo/coverage",
    "coverageReporters": [
      "json",
      "text",
      "lcov",
      "clover"
    ],
    "coverageThreshold": null,
    "detectLeaks": false,
    "detectOpenHandles": false,
    "errorOnDeprecated": false,
    "expand": false,
    "filter": null,
    "globalSetup": null,
    "globalTeardown": null,
    "json": false,
    "listTests": false,
    "maxConcurrency": 5,
    "maxWorkers": 3,
    "noStackTrace": false,
    "nonFlagArgs": [
      "unit-test/async-await.test.js",
      "unit-test/callback.test.js",
      "unit-test/everyDataType.test.js",
      "unit-test/json.test.js",
      "unit-test/mock.test.js",
      "unit-test/promise.test.js"
    ],
    "notify": false,
    "notifyMode": "failure-change",
    "onlyChanged": false,
    "passWithNoTests": false,
    "projects": null,
    "rootDir": "/Users/chris/code/jest-demo",
    "runTestsByPath": true,
    "skipFilter": false,
    "testFailureExitCode": 1,
    "testPathPattern": "unit-test/async-await.test.js|unit-test/callback.test.js|unit-test/everyDataType.test.js|unit-test/json.test.js|unit-test/mock.test.js|unit-test/promise.test.js",
    "testResultsProcessor": null,
    "testSequencer": "/Users/chris/code/jest-demo/node_modules/@jest/test-sequencer/build/index.js",
    "updateSnapshot": "new",
    "useStderr": false,
    "verbose": null,
    "watch": false,
    "watchman": true
  },
  "version": "24.9.0"
}

差异键

  • 非标志参数
  • 仅改变
  • 按路径运行测试
  • 测试路径模式

相关内容