-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.spec.js
37 lines (34 loc) · 1.3 KB
/
index.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { queryAllByText } from "dom-testing-library";
import { findByText, findByLabelText } from "dom-testing-addon-async";
import user from "user-event";
describe("Home page", () => {
it("successfully loads", async function(done) {
cy.visit("/").then(async function({ document: { body } }) {
let rightHeader = await findByText(body, "Hello, world");
let wrongHeaders = queryAllByText(body, "Hello, moon");
expect(wrongHeaders).to.have.length(0); // chai
expect(rightHeader).toBeInTheDocument(); // jest-dom
done();
});
});
});
describe("Counter page", () => {
it("increments counter", async function(done) {
cy.visit("/counter").then(async function({ document: { body } }) {
user.click(await findByText(body, "Click me"));
expect(await findByLabelText(body, "Click count")).toHaveTextContent("1");
done();
});
});
});
describe("Navigation", () => {
it("can go between pages", async function(done) {
cy.visit("/").then(async function({ document: { body } }) {
user.click(await findByText(body, "Counter Game"));
expect(await findByLabelText(body, "Click count")).toHaveTextContent("0");
user.click(await findByText(body, "Home"));
expect(body.ownerDocument.location.pathname).to.equal("/");
done();
});
});
});