Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export as esModule #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Export as esModule #2

wants to merge 1 commit into from

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