Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: Initialize end to end testing #238

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/
14 changes: 12 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,10 @@ godoc: install
# --- frontend -----------------------------------------------------------------
NODEPREFIX = .hermit/node
NODELIB = $(NODEPREFIX)/lib
# TODO: BASEURL should be calculated dynamically for CI/PR.
# BASEURL needs to be in the environment so that `e2e/playwright.config.js`
# can see it when the `e2e` target is called.
export BASEURL = https://evy.dev

## Serve frontend on free port
serve:
Expand All @@ -140,10 +144,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",
},
})