Skip to content

Commit

Permalink
docs: removing reference to SVGR ReactComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjoy committed Jul 9, 2024
1 parent fac00dd commit b685edc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ Then, create a `src/__mocks__` folder and add the necessary mocks.
**svg.js:**

```
export default 'SvgrURL';
export const ReactComponent = 'SvgMock';
module.exports = 'SvgURL';
```

**file.js:**
Expand All @@ -146,7 +145,7 @@ export const ReactComponent = 'SvgMock';
module.exports = 'FileMock';
```

You can change the values of "SvgrURL", "SvgMock", and "FileMock" if you want to reduce changes necessary to your snapshot tests; the old values from frontend-build assume svg is only being used for icons, so the values referenced an "icon" which felt unnecessarily narrow.
You can change the values of "SvgURL", and "FileMock" if you want to reduce changes necessary to your snapshot tests; the old values from frontend-build assume svg is only being used for icons, so the values referenced an "icon" which felt unnecessarily narrow.

This is necessary because we cannot write a tsconfig.json in MFEs that includes transpilation of the "config/jest" folder in frontend-base, it can't meaningfully find those files and transpile them, and we wouldn't want all MFEs to have to include such idiosyncratic configuration anyway. The SVG mock, however, requires ESModules syntax to export its default and ReactComponent exports at the same time. This means without moving the mocks into the MFE code, the SVG one breaks transpilation and doesn't understand the `export` syntax used. By moving them into the MFE, they can be easily transpiled along with all the other code when jest tries to run.

Expand Down
2 changes: 1 addition & 1 deletion cli/test-app/src/__mocks__/file.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = 'FileMock';
export default 'FileMock';
1 change: 0 additions & 1 deletion cli/test-app/src/__mocks__/svg.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export default 'SvgURL';
export const ReactComponent = 'SvgMock';

0 comments on commit b685edc

Please sign in to comment.