This example demonstrates how to use jest-preview
with create-react-app
.
jest is setup with create-react-app by default, we don't need to do anything more
Please refer to Installation and Usage.
Except for step 2 of installation: Create fileTransform.js
:
- Because
create-react-app
allows user to use svg files as React components,jest-preview
therefore needs to support that, so we use the below config:
// config/jest/fileTransform.js
const { processFileCRA } = require('jest-preview');
module.exports = {
process(src, filename) {
return processFileCRA(src, filename);
},
};