简体   繁体   English

如何gitignore快照文件夹?

[英]How to gitignore snapshot folders?

I am starting to learn more about Jest and testing such as snapshot testing. 我开始了解有关Jest和测试(如快照测试)的更多信息。 The way I have my components in react configured is... 我配置反应配置的方式是......

- src
  - components
    - Component1
      - index.js
      - __tests__
        - Component1.test.js
        - __snapshots__
  - Component2
      - index.js
      - __tests__
        - Component2.test.js
        - __snapshots__

and so on. 等等。

I'm wondering what would be the line to write in my .gitignore to ignore the __snapshots__ folder with this structure. 我想知道在我的.gitignore写入什么行以忽略具有此结构的__snapshots__文件夹。

Currently I have this (which is wrong) 目前我有这个(这是错的)

/src/components/*/__snapshots__/

Also, is it best to keep them in version control or to ignore them? 另外,最好是将它们保留在版本控制中还是忽略它们? I'd still like to know what I need to put in my gitignore , but would like to hear thoughts about this as well! 我仍然想知道我需要把什么放在我的gitignore ,但是也希望听到关于这个的想法!

Thank you! 谢谢!

I had the same question and ended up finding this post here. 我有同样的问题,最后在这里找到这篇文章。 However, Jest documentation states that: 但是,Jest文档指出:

all snapshot files should be committed alongside the modules they are covering and their tests 所有快照文件应与它们所涵盖的模块及其测试一起提交

Hope this helps others as has helped me. 希望这对帮助我的人有所帮助。

Source: https://jestjs.io/docs/en/snapshot-testing.html#should-snapshot-files-be-committed 资料来源: https//jestjs.io/docs/en/snapshot-testing.html#should-snapshot-files-be-committed

ignore the folder called snapshots anywhere, but not files with the same name 忽略任何地方名为snapshots的文件夹,但不忽略具有相同名称的文件

__snapshots__/

Since this has a “/” at the end only directories would be matched – removing it would also make the pattern catch files with the same name. 因为它在末尾只有一个“/”,所以只匹配目录 - 删除它也会使模式捕获具有相同名称的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM