English 中文(简体)
观察——所有检测都总是进行
原标题:Jest --watch runs all tests always

I recently switched from Mocha to Jest. Everything works fine except the watch mode which always runs all tests (not only tests related to uncommited files as it says in the docs). I ve searched the docs and with google but I haven t found any information on this issue.

我的 j是

  "jest": {
    "coveragePathIgnorePatterns": [
      "/node_modules/",
      "/generated/",
      "/mock/",
      "/tools/",
      "/transactions/"
    ],
    "coverageThreshold": {
      "global": {
        "branches": 90,
        "functions": 90,
        "lines": 90,
        "statements": 90
      }
    },
    "resetMocks": true,
    "moduleDirectories": [
      "node_modules",
      "src"
    ],
    "moduleNameMapper": {
      "\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/__mocks__/fileMock.js",
      "\.(css|less|scss)$": "<rootDir>/src/__mocks__/styleMock.js"
    },
    "setupTestFrameworkScriptFile": "<rootDir>/tools/setupTest.js"
  },

http://www.un.org/Depts/DGACM/index_french.htm 页: 1

require( babel-polyfill );

Babelrc:

 "env": {
    "test": {
      "plugins": [
        "rewire",
        "transform-class-properties",
        "transform-es2015-modules-commonjs"
      ],
      "presets": [
        "es2017",
        "react",
        "stage-0",
        "es2015"
      ]
    }
  }

我开始用<代码>jest-watch进行测试,并打印“确定操作的试验程序”的讯息,但所有测试都在,即使没有任何文件未经编辑<>。

I m on windows 7 and I run the command in powershell. Node version: v6.9.1
Jest versions: "babel-jest": "20.0.3", "jest": "20.0.4"

问题回答

In all honesty, I m guessing, but try using testPathIgnorePatterns in addition to coveragePathIgnorePatterns.

You need a git repo to run www.un.org/Depts/DGACM/index_spanish.htm (jest --watch implicitly uses it).

http://jestjs.io/docs/cli#running- from-the-command-line”rel=“nofollow noreferer” docs :

与根据 hg/git(未交档案)修改的档案有关的动态测试:

www.un.org/Depts/DGACM/index_spanish.htm

I am using Jest v27.6.3 and gitbash, not sure if this is a new feature, but you don t have to wait for the all tests to run, you can interrupt it by pressing enter key and it will stop running and ask for input from the user: enter image description here





相关问题
How to change return value of mocked class method

I have a mocked class of a node module and its method as below, and test case to test case I need to change the methodOne returning value. jest.mock("module_name", () => { return { ...

Why LD SDK Jest Test MockFlags Returning Undefined

So I have a component that checks a flag and based on if the flag returns true or false, we do something with it. The issue I have is when I am mocking according to LD documentation, the flag is ...

how to mock function in react js?

I am trying to do/write unit test of below function. import { getDetail } from "./api"; export const fetchDetail = async (jobNumber) => { try { const response = await getDetail(...