Skip to content

Instantly share code, notes, and snippets.

@Goldziher
Created August 1, 2021 06:46
Show Gist options
  • Save Goldziher/180256e706dcd8f721e3b1563d89d147 to your computer and use it in GitHub Desktop.
Save Goldziher/180256e706dcd8f721e3b1563d89d147 to your computer and use it in GitHub Desktop.
Example of using FixtureFactory in a snapshot test
import { UserDTOFactory } from '@shared/factories/User.dto.factory';
import { render } from '@testing-library/react';
import UserProfile from '@frontend/pages/user-profile';
describe('UserProfile', () => {
it('matches snapshot', () => {
const user = UserDTOFactory.fixtureSync(
__dirname + '/UserProfile.spec.json',
)
const { container } = render(<UserProfile user={user} /> );
expect(container).toMatchSnapshot()
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment