Skip to content

Commit

Permalink
fix(workshop): 🐛 snapshot not correct
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicoss54 committed Nov 5, 2023
1 parent a2a679d commit 22af111
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
9 changes: 2 additions & 7 deletions 02-wrap-solution/src/app/app.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ import { render } from '@testing-library/react';
import App from './app';
describe('App', () => {
let container: HTMLElement;
let asFragment: any;

beforeEach(() => {
const { asFragment: snapshot, container: host } = render(<App />);
asFragment = snapshot;
container = host;
});
const { container: host } = render(<App />);

test('should display a snapshot of App', () => {
expect(asFragment(<App />)).toMatchSnapshot();
container = host;
});

test('should display in h1 tag the text "Hello Students', () => {
Expand Down
9 changes: 2 additions & 7 deletions 03-component-solution/src/app/app.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ import { render } from '@testing-library/react';
import App from './app';
describe('App', () => {
let container: HTMLElement;
let asFragment: any;

beforeEach(() => {
const { asFragment: snapshot, container: host } = render(<App />);
asFragment = snapshot;
container = host;
});
const { container: host } = render(<App />);

test('should display a snapshot of App', () => {
expect(asFragment(<App />)).toMatchSnapshot();
container = host;
});
test('should display the main tag with the class people-application', () => {
const mainElement = container.querySelector('main.people-application') as HTMLElement;
Expand Down
8 changes: 1 addition & 7 deletions 03-component/src/app/app.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ import { render } from '@testing-library/react';
import App from './app';
describe('App', () => {
let container: HTMLElement;
let asFragment: any;

beforeEach(() => {
const { asFragment: snapshot, container: host } = render(<App />);
asFragment = snapshot;
const { container: host } = render(<App />);
container = host;
});

test('should display a snapshot of App', () => {
expect(asFragment(<App />)).toMatchSnapshot();
});

test('should display in h1 tag the text "Hello Students', () => {
const h1Element = container.querySelector('h1') as HTMLHeadingElement;
expect(h1Element.textContent?.trim()).toEqual('Hello Students');
Expand Down

0 comments on commit 22af111

Please sign in to comment.