Skip to content

Commit

Permalink
e2e: Initialize end to end testing
Browse files Browse the repository at this point in the history
Initialize end to end testing in top level directory e2e. Everything related
to end to end testing will be in this directory. Initialize node package
with

    echo '{"private": true}' > e2e/package.json
    npm install --save-dev --prefix e2e playwright
    npm install --save-dev --prefix e2e @playwright/test@latest

Add `node_modules/` to .gitignore.

Setup basic playwright test config that will allow to parametrize the baseURL
of tests.

Add a minimal index.test.js test file that loads the Evy playground index.html
page. It runs two tests on it:

- ensure the title is "Evy | Playground"
- execute `Run` and ensure the console output contains expected test.
  • Loading branch information
juliaogris committed Jan 9, 2024
1 parent 2997529 commit 17469d3
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/.hermit/
/e2e/test-results
/firebase/*.log
/firebase/.firebase/
/frontend/evy.wasm
/frontend/version.json
/frontend/wasm_exec.js
/out/

node_modules/
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ all: build test lint tiny test-tiny check-coverage sh-lint check-prettier check-
@if [ -e .git/rebase-merge ]; then git --no-pager log -1 --pretty='%h %s'; fi
@echo '$(COLOUR_GREEN)Success$(COLOUR_NORMAL)'

ci: clean check-uptodate all ## Full clean build and up-to-date checks as run on CI
ci: clean check-uptodate all e2e ## Full clean build and up-to-date checks as run on CI

check-uptodate: tidy fmt doc
test -z "$$(git status --porcelain)" || { git status; false; }
Expand Down Expand Up @@ -127,6 +127,8 @@ godoc: install
# --- frontend -----------------------------------------------------------------
NODEPREFIX = .hermit/node
NODELIB = $(NODEPREFIX)/lib
# TODO: BASEURL should be calculated dynamically for CI/PR.
export BASEURL ?= https://evy.dev

## Serve frontend on free port
serve:
Expand All @@ -140,10 +142,16 @@ prettier: | $(NODELIB)
check-prettier: | $(NODELIB)
npx --prefix $(NODEPREFIX) -y prettier --check .

e2e:
@echo "testing $(BASEURL)"
npm --prefix e2e ci
npx --prefix e2e playwright install --with-deps chromium
npx --prefix e2e playwright test --config e2e

$(NODELIB):
@mkdir -p $@

.PHONY: check-prettier prettier serve
.PHONY: check-prettier e2e prettier serve

# --- deploy -----------------------------------------------------------------

Expand Down
15 changes: 15 additions & 0 deletions e2e/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { test, expect } = require("@playwright/test")

test("title", async ({ page, baseURL }) => {
await page.goto(baseURL)
await expect(page).toHaveTitle("evy | Playground")
})

test("console output", async ({ page, baseURL }) => {
await page.goto(baseURL)
await page.waitForLoadState("networkidle")
await page.getByRole("button", { name: "Run" }).click()
const console = page.locator("css=#console")
await expect(console).toContainText("x: 12")
await expect(console).toContainText("🍦 big x")
})
72 changes: 72 additions & 0 deletions e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"private": "true",
"devDependencies": {
"@playwright/test": "^1.40.1",
"playwright": "^1.40.1"
}
}
6 changes: 6 additions & 0 deletions e2e/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { defineConfig, devices } = require("@playwright/test")
module.exports = defineConfig({
use: {
baseURL: process.env.BASEURL || "http://localhost:8080",
},
})

0 comments on commit 17469d3

Please sign in to comment.