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

javascript - Ignore e2e folder when running npm test - Stack Overflow

programmeradmin1浏览0评论

I am using detox as the end-2-end tester for my react-native app but I don't want whats in the e2e folder to be included when I run npm test. I am currently using jest for the npm test.

This is what i have in my package.json:

 "jest": {
        "preset": "react-native",
        "transformIgnorePatterns": [
          "node_modules/(?!(react-native|static-container|expo|@expo|react-navigation))"
        ]
      }, 

The e2e folder is located in my root directory and my test files are in my tests folder in the root directory also.

I am using detox as the end-2-end tester for my react-native app but I don't want whats in the e2e folder to be included when I run npm test. I am currently using jest for the npm test.

This is what i have in my package.json:

 "jest": {
        "preset": "react-native",
        "transformIgnorePatterns": [
          "node_modules/(?!(react-native|static-container|expo|@expo|react-navigation))"
        ]
      }, 

The e2e folder is located in my root directory and my test files are in my tests folder in the root directory also.

Share Improve this question edited Feb 28, 2019 at 14:31 skyboyer 23.8k7 gold badges62 silver badges71 bronze badges asked Feb 28, 2019 at 14:14 Liam RamsbottomLiam Ramsbottom 1874 silver badges15 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

To get around this problem when I run my jest tests I use the testMatch property and set it in the package.json this means that it will only match the tests that are in the folders that I have specified.

"jest": {
  "preset": "react-native",
  "testMatch": [
  "<rootDir>/__tests__/**/*.test.js?(x)",
  "<rootDir>/app/**/*.test.js"
  ]
},

Alternatively you can use to ignore specific paths.

"jest": {
  "preset": "react-native",
  "testPathIgnorePatterns": [
    "<rootDir>/e2e"
  ]
},
发布评论

评论列表(0)

  1. 暂无评论