Run only ONE test with Jest

后端 未结 4 1182
借酒劲吻你
借酒劲吻你 2020-12-28 11:10

Very simple, I want to run just one test with Jest.

I put it.only or describe.only but it still runs a whole lot of tests. I think it runs

4条回答
  •  眼角桃花
    2020-12-28 12:03

    it.only and describe.only work only for the module they are in. If you are having problems to filter tests in multiple files, you can use jest -t name-of-spec, filtering tests that match the spec name (match against the name in describe or test).
    Source: https://facebook.github.io/jest/docs/en/cli.html

    For example, I focus the test which I'm currently writing like this (with the test script in the package.json):
    npm test -- -t "test foo"

提交回复
热议问题