I am starting to learn more about Jest and testing such as snapshot testing. 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.
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!
Thank you!
How to Ignore a File and Folder in Git. If you want to ignore only one specific file, you need to provide the full path to the file from the root of the project. If you want to ignore all files with a specific name, you need to write the literal name of the file.
gitignore file is a text file that tells Git which files or folders to ignore in a project. A local . gitignore file is usually placed in the root directory of a project. You can also create a global . gitignore file and any entries in that file will be ignored in all of your Git repositories.
Open Visual Studio and the solution needing an ignore file. From the top menu select Git > Settings. The above will open Visual Studio's Options with Source Control > Git Global Settings selected. From the list on the left select Git Repository Settings and then click the Add button for Ignore file.
gitignore files. This file lists files that are intentionally untracked and should be ignored by Git. It is important to note that changes to files that were staged before being added to the . gitignore file will continue to be tracked by Git.
ignore the folder called snapshots anywhere, but not files with the same name
__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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With