4ba5b368a6
Use Testcafé e2e tests for all kinds of frontend testing
37 lines
1.1 KiB
TypeScript
37 lines
1.1 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("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");
|
|
const text = await header.textContent;
|
|
await t.expect(text).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");
|
|
}); |