diff --git a/package.json b/package.json index 72c3d32..beaa289 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/testcafe/index.test.ts b/tests/testcafe/index.test.ts index 5260496..b797779 100644 --- a/tests/testcafe/index.test.ts +++ b/tests/testcafe/index.test.ts @@ -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); });