Ad
Jest Test Formatting -- __tests__ Vs *.test.js
I'm working in a react codebase where we have test files labeled
__tests__
The files inside look like this
filename.js
Previously when I've used jest/enzyme, I've had test files formatted like this
filename.test.js
I am assuming that when you put a file inside a folder with the title
__tests__
you can leave the .test part off? I can't seem to find a solid answer on topic. Does anyone have some insight into the formatting functionality?
Ad
Answer
This is because of the value of jest config's testMatch
property which defaults to
[ "**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)" ]
Which basically means that it will consider as a test any js(x) or ts(x) file either with .test (or .spec) after it or inside a __test__
folder.
Ad
source: stackoverflow.com
Related Questions
- → Import statement and Babel
- → should I choose reactjs+f7 or f7+vue.js?
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → .tsx webpack compile fails: Unexpected token <
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → React Native with visual studio 2015 IDE
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
- → How do I determine if a new ReactJS session and/or Browser session has started?
- → Alt @decorators in React-Native
- → How to dynamically add class to parent div of focused input field?
Ad