npm init -y
to setup a new projectnpm i --save-dev jest babel-jest @babel/preset-env
to install all required packages- Create
jest.config.js
with the content shown below - Create
babel.config.json
with the content shown below
With this setup, we can create JavaScript files and test them in separate test files. To run the tests, use npm run test
module.exports = {
verbose: true,
transform: {
"^.+\\.jsx?$": "babel-jest"
}
};
{
"presets": ["@babel/preset-env"]
}