Refactor tests

This commit is contained in:
Jan Tuomi
2018-06-22 11:52:58 +03:00
parent f7059eefbe
commit c34664f556
2 changed files with 6 additions and 8 deletions
+4 -2
View File
@@ -27,8 +27,9 @@
"start-prod": "npm run build && npm run serve",
"mock-backend": "json-server --watch db.json -p 1234",
"test": "npm-run-all lint test:e2e",
"test:e2e": "npm-run-all -s build -p -r mock-backend serve test:e2e:run",
"test:e2e:run": "testcafe -S -s 'tests/testcafe/screenshots' --app-init-delay 2000 chrome tests/testcafe",
"test:e2e": "npm-run-all -s build test:e2e:run",
"test:e2e:run": "npm-run-all -p -r mock-backend serve test:e2e:testcafe",
"test:e2e:testcafe": "testcafe -S -s 'tests/testcafe/screenshots' --app-init-delay 2000 chrome tests/testcafe",
"plop": "plop"
},
"husky": {
@@ -74,6 +75,7 @@
"stylelint-config-standard": "^18.2.0",
"stylelint-webpack-plugin": "^0.10.5",
"testcafe": "^0.20.3",
"testcafe-react-selectors": "^2.1.0",
"tslint": "^5.10.0",
"uglifyjs-webpack-plugin": "^1.2.5",
"webpack": "^4.11.1",
+2 -6
View File
@@ -5,7 +5,7 @@
*/
import { Selector } from "testcafe";
fixture`Page renders correctly`.page("http://localhost:3000");
fixture`Front page renders and functions correctly`.page("http://localhost:3000");
test("Favicon exists", async t => {
/**
@@ -32,8 +32,6 @@ test("Header contains text \"Aalto-yliopiston sähköinsinöörikilta!\"", async
.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
@@ -44,12 +42,10 @@ test("Increment button functions correctly", async t => {
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();
await t.expect(post.count).gte(1);
});