Files
web2.0-frontend/tests/testcafe/index.test.ts
T
2018-06-22 10:43:06 +03:00

56 lines
1.6 KiB
TypeScript

/**
* TestCafé test fixtures.
* This file is used by TestCafé to run end-to-end tests with chrome against the site.
* Tests are grouped into fixtures and fixtures into files.
*/
import { Selector } from "testcafe";
fixture`Page renders correctly`.page("http://localhost:3000");
test("Favicon exists", async t => {
/**
* Test if there is a favicon element on the page
*/
const elem = Selector("link[rel=\"icon\"");
await t.expect(elem.exists).ok();
});
test("Paragraph exists and is visible", async t => {
/**
* Test if there is a paragraph on the page.
*/
const p = Selector("p");
await t.expect(p.exists).ok();
});
test("Header contains text \"Aalto-yliopiston sähköinsinöörikilta!\"", async t => {
/**
* Test if the header contains the text.
*/
const header = Selector("h1");
await t.expect(header.textContent)
.contains("Aalto-yliopiston sähköinsinöörikilta!");
});
fixture`Increment button`.page("http://localhost:3000");
test("Increment button functions correctly", async t => {
/**
* Test if the increment button works and increments the number inside the button
*/
const button = Selector("button");
await t.expect(button.textContent).contains("0");
await t.click(button);
await t.expect(button.textContent).contains("1");
});
fixture`Posts from API`.page("http://localhost:3000");
test("At least one post exists", async t => {
/**
* Test if the API responds with at least one post and it is rendered to the page
*/
const post = Selector(".post");
await t.expect(post.exists).ok();
});