最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to use testNamePattern of jest within package.json scripts field? - Stack Overflow

programmeradmin5浏览0评论

Honestly, jest of facebook has a bad document.

I want to use jest -t xxx to update my snapshots.

Here is my test, but no one works correctly.

  1. jest -u -t='test.tsx'

  2. jest -u -t 'test.tsx'

  3. jest -u -t /test.tsx/

  4. jest -u -t=/test.tsx/

I want to match and update snapshots test files which filename pattern like *.test.tsx.

How can I do that with jest testNamePattern?

Honestly, jest of facebook has a bad document.

I want to use jest -t xxx to update my snapshots.

Here is my test, but no one works correctly.

  1. jest -u -t='test.tsx'

  2. jest -u -t 'test.tsx'

  3. jest -u -t /test.tsx/

  4. jest -u -t=/test.tsx/

I want to match and update snapshots test files which filename pattern like *.test.tsx.

How can I do that with jest testNamePattern?

Share Improve this question asked Jul 11, 2017 at 11:24 Lin DuLin Du 103k135 gold badges334 silver badges565 bronze badges 1
  • have you tried jest -u -t '*.test.tsx' ? – JoeTidee Commented Jul 24, 2017 at 11:18
Add a ment  | 

1 Answer 1

Reset to default 9

First check jest --showConfig to see that you even have the option of --testNamePattern. I faced the same issue, and did not find this option in jest config.

So I changed my directory structure and used --testPathPattern option with regex. This works.

jest --testPathPattern='(tests)/spec/./snapshot-tests/.'

发布评论

评论列表(0)

  1. 暂无评论