Skip to content

Commit

Permalink
Test to check Welcome component renders a header
Browse files Browse the repository at this point in the history
Relates #66
  • Loading branch information
mkatenolan committed Oct 7, 2019
1 parent c38c715 commit c099993
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 1 deletion.
143 changes: 143 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
]
},
"devDependencies": {
"@testing-library/jest-dom": "^4.1.0",
"@testing-library/react": "^9.3.0",
"cypress": "^3.4.1"
}
}
2 changes: 1 addition & 1 deletion src/components/Welcome/Welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
const Welcome = () => {
return (
<div>
<h1>Welcome</h1>
<h1 data-testid="welcome-header">Welcome</h1>
<p> Welcome to the My Body Back app </p>
<img src="#"/><p>This icon will take you to the "Support & Techniques" section </p>
<img src="#"/><p>This icon will take you to the "Feeling Overwhelmed" section </p>
Expand Down
17 changes: 17 additions & 0 deletions src/components/Welcome/Welcome.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { render, fireEvent, cleanup, waitForElement, queryByTestId} from "@testing-library/react";
import { toBeInTheDocument } from "@testing-library/jest-dom/";
import Welcome from './Welcome.js';

test('Jest works ok', () => {
expect(true).toBeTruthy();
});

describe('Welcome component renders to page', () => {
test('Welcome component renders header', () => {
const { getByTestId } = render(<Welcome />);
const header = getByTestId("welcome-header");
expect(header).toBeInTheDocument()

});
});

0 comments on commit c099993

Please sign in to comment.