-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: Add unit tests * ci: preview deployments * ci: preview deployments * ci: preview deployments * ci: preview deployments * ci: remove preview deployments * fix(ci): copy files on CI and windows instead of symlink * fix(ci): copy files on CI and windows instead of symlink * fix: preview command * fix: preview command
- Loading branch information
Showing
19 changed files
with
637 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: CI | ||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
test: | ||
# Prevent workflow being run twice, https://github.com/orgs/community/discussions/57827#discussioncomment-6579237 | ||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | ||
|
||
name: ${{ matrix.cmd }} (${{ matrix.os }}) | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
# Don't cancel other matrix operations if one fails | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- windows-latest | ||
cmd: | ||
- pnpm run test:e2e | ||
- pnpm run test:units | ||
- pnpm run test:types | ||
# `exclude` docs & alternatives: | ||
# - https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixexclude | ||
# - https://stackoverflow.com/questions/68994484/how-to-skip-a-configuration-of-a-matrix-with-github-actions/68994907#68994907 | ||
# - https://stackoverflow.com/questions/66025220/paired-values-in-github-actions-matrix/68940067#68940067 | ||
exclude: | ||
- os: windows-latest | ||
cmd: pnpm run test:types | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: "pnpm" | ||
|
||
- run: pnpm install | ||
- run: pnpm exec playwright install chromium | ||
- run: pnpm run build | ||
|
||
- run: ${{ matrix.cmd }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,3 +130,6 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# Cloudflare | ||
.wrangler/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
package-manager-strict=false | ||
link-workspace-packages=deep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { testRun } from './.testRun' | ||
testRun('pnpm run dev') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { testRun } from "./.testRun"; | ||
|
||
testRun("pnpm run preview --port 3000", { | ||
doNotFailOnWarning: true, | ||
serverIsReadyMessage: "Starting local server", | ||
serverIsReadyDelay: 2000, | ||
serverUrl: "http://127.0.0.1:3000", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { expect, fetchHtml, getServerUrl, page, run, test } from "@brillout/test-e2e"; | ||
|
||
export { testRun }; | ||
|
||
let isProd: boolean; | ||
|
||
function testRun(cmd: `pnpm run ${"dev" | "preview"}${string}`, options?: Parameters<typeof run>[1]) { | ||
run(cmd, options); | ||
|
||
isProd = cmd !== "pnpm run dev"; | ||
|
||
testUrl({ | ||
url: "/", | ||
title: "My Vike App", | ||
text: "built with https://github.com/vikejs/vike-solid", | ||
textHydration: "Rendered to HTML", | ||
}); | ||
|
||
testUrl({ | ||
url: "/star-wars", | ||
title: "6 Star Wars Movies", | ||
text: "A New Hope", | ||
}); | ||
|
||
testUrl({ | ||
url: "/star-wars/3", | ||
title: "Return of the Jedi", | ||
text: "1983-05-25", | ||
}); | ||
} | ||
|
||
function testUrl({ | ||
url, | ||
title, | ||
text, | ||
textHydration, | ||
noSSR, | ||
}: { | ||
url: string; | ||
title: string; | ||
text: string; | ||
textHydration?: string; | ||
counter?: true; | ||
noSSR?: true; | ||
}) { | ||
test(url + " (HTML)", async () => { | ||
const html = await fetchHtml(url); | ||
if (!noSSR) { | ||
expect(html).toContain(text); | ||
} | ||
expect(getTitle(html)).toBe(title); | ||
}); | ||
test(url + " (Hydration)", async () => { | ||
await page.goto(getServerUrl() + url); | ||
const body = await page.textContent("body"); | ||
expect(body).toContain(textHydration ?? text); | ||
}); | ||
} | ||
|
||
function getTitle(html: string) { | ||
const title = html.match(/<title>(.*?)<\/title>/i)?.[1]; | ||
return title; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,5 @@ export default { | |
Head, | ||
// <title> | ||
title: "My Vike App", | ||
stream: "web", | ||
extends: vikeSolid, | ||
} satisfies Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { Config } from "vike/types"; | ||
|
||
// Default config (can be overridden by pages) | ||
export default { | ||
stream: "web", | ||
} satisfies Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { testRun } from './.testRun' | ||
testRun('pnpm run dev') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { testRun } from "./.testRun"; | ||
|
||
testRun("pnpm run preview --port 3000", { | ||
doNotFailOnWarning: true, | ||
serverIsReadyMessage: "Starting local server", | ||
serverIsReadyDelay: 2000, | ||
serverUrl: "http://127.0.0.1:3000", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { expect, fetchHtml, getServerUrl, page, run, test } from "@brillout/test-e2e"; | ||
|
||
export { testRun }; | ||
|
||
let isProd: boolean; | ||
|
||
function testRun(cmd: `pnpm run ${"dev" | "preview"}${string}`, options?: Parameters<typeof run>[1]) { | ||
run(cmd, options); | ||
|
||
isProd = cmd !== "pnpm run dev"; | ||
|
||
testUrl({ | ||
url: "/", | ||
title: "My Vike App", | ||
text: "built with https://github.com/vikejs/vike-solid", | ||
textHydration: "Rendered to HTML", | ||
}); | ||
|
||
testUrl({ | ||
url: "/star-wars", | ||
title: "6 Star Wars Movies", | ||
text: "A New Hope", | ||
}); | ||
|
||
testUrl({ | ||
url: "/star-wars/3", | ||
title: "Return of the Jedi", | ||
text: "1983-05-25", | ||
}); | ||
} | ||
|
||
function testUrl({ | ||
url, | ||
title, | ||
text, | ||
textHydration, | ||
noSSR, | ||
}: { | ||
url: string; | ||
title: string; | ||
text: string; | ||
textHydration?: string; | ||
counter?: true; | ||
noSSR?: true; | ||
}) { | ||
test(url + " (HTML)", async () => { | ||
const html = await fetchHtml(url); | ||
if (!noSSR) { | ||
expect(html).toContain(text); | ||
} | ||
expect(getTitle(html)).toBe(title); | ||
}); | ||
test(url + " (Hydration)", async () => { | ||
await page.goto(getServerUrl() + url); | ||
const body = await page.textContent("body"); | ||
expect(body).toContain(textHydration ?? text); | ||
}); | ||
} | ||
|
||
function getTitle(html: string) { | ||
const title = html.match(/<title>(.*?)<\/title>/i)?.[1]; | ||
return title; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,11 @@ | |
"scripts": { | ||
"build": "cd packages/vike-cloudflare && pnpm run build", | ||
"release": "cd packages/vike-cloudflare && pnpm run release", | ||
"========= Test": "", | ||
"test": "pnpm run test:units && pnpm run test:e2e && pnpm run test:types", | ||
"test:e2e": "test-e2e", | ||
"test:units": "pnpm --recursive --sequential --filter {packages/*} run test", | ||
"test:types": "test-types", | ||
"========= Formatting": "", | ||
"format": "git ls-files | egrep '\\.(json|js|jsx|css|ts|tsx|vue|mjs|cjs)$' | grep --invert-match package.json | xargs pnpm exec prettier --write", | ||
"lint": "eslint .", | ||
|
@@ -13,13 +18,21 @@ | |
}, | ||
"keywords": [], | ||
"author": "", | ||
"pnpm": { | ||
"overrides": { | ||
"vike-cloudflare": "link:./packages/vike-cloudflare/" | ||
} | ||
}, | ||
"devDependencies": { | ||
"@ianvs/prettier-plugin-sort-imports": "^4.2.1", | ||
"@typescript-eslint/eslint-plugin": "^7.13.1", | ||
"@typescript-eslint/parser": "^7.13.1", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-solid": "^0.14.1", | ||
"prettier": "^3.3.2" | ||
"prettier": "^3.3.2", | ||
"@brillout/test-e2e": "^0.5.33", | ||
"@brillout/test-types": "^0.1.15", | ||
"playwright": "^1.42.1" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.