Get test URL from process.env

This commit is contained in:
Aarni Halinen
2021-01-12 22:51:07 +02:00
parent 5401445626
commit e4e18c1d4f
5 changed files with 15 additions and 22 deletions
+4 -7
View File
@@ -1,11 +1,8 @@
/**
* 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`404 page renders and functions correctly`.page("http://localhost:3000/404");
import { Selector } from "testcafe";
import { getSiteRoot } from "./utils";
fixture`404 page renders and functions correctly`.page(`${getSiteRoot}/404`);
test("Page contains the text 404", async t => {
/**
+3 -7
View File
@@ -1,11 +1,7 @@
/**
* 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, ClientFunction } from "testcafe";
import { getSiteRoot } from "./utils";
fixture`Admin login page functions correctly`.page("http://localhost:3000/admin/login");
fixture`Admin login page functions correctly`.page(`${getSiteRoot}/admin/login`);
test("Login form exists", async t => {
/**
@@ -26,7 +22,7 @@ test("User can log in with default credentials", async t => {
await t.typeText(Selector("#login-password"), PASSWORD);
await t.click(Selector("#login-submit"));
const frontPage = Selector(`[data-e2e="admin-front-page"]`);
const frontPage = Selector("[data-e2e=\"admin-front-page\"]");
await t.expect(frontPage.exists).ok();
});
+3 -7
View File
@@ -1,11 +1,7 @@
/**
* 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";
import { getSiteRoot } from "./utils";
fixture`Front page renders and functions correctly`.page("http://localhost:3000");
fixture`Front page renders and functions correctly`.page(`${getSiteRoot}`);
test("Favicon exists", async t => {
/**
@@ -21,5 +17,5 @@ test("Header contains text \"Aalto-yliopiston Sähköinsinöörikilta\"", async
*/
const header = Selector("h1");
await t.expect(header.textContent)
.contains("Aalto-yliopiston Sähköinsinöörikilta");
.contains("Aalto-yliopiston Sähköinsinöörikilta");
});
+3
View File
@@ -0,0 +1,3 @@
export const getSiteRoot = () => {
return process.env.SITE_URL || "http://localhost:3000";
}