Skip to content

Conversation

ChromeQ
Copy link

@ChromeQ ChromeQ commented Mar 24, 2022

Attempt to fix #1

Not sure on the implications of this on a non es module project but it should be ok as create react app do this https://github.com/facebook/create-react-app/blob/efc3581e075ee049179029c982c5a10d0d2a3300/packages/react-scripts/config/jest/fileTransform.js#L22 and that works fine for regular projects.

@ChromeQ
Copy link
Author

ChromeQ commented Mar 24, 2022

And just confirming this change still works as expected with

import { ReactComponent as Icon } from '@images/icon-trophy.svg';
...
describe('svg icon', () => {
            fit('should render the svg element', async () => {
                render(<Icon />);
                screen.debug();
            });
        });
...

Outputs:

console.log
      <body>
        <div
          data-testid="app-container"
        >
          <svg
            data-jest-file-name="icon-trophy.svg"
            data-jest-svg-name="icon-trophy"
            data-testid="icon-trophy"
          />
        </div>
      </body>

@garvae
Copy link

garvae commented Aug 11, 2022

@half-halt Come on man add this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image src displays as [object Object]
2 participants