Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix e2e + add ecosystem-ci test script (#311)
* chore: add ecosystem-ci scripts * chore: lint * chore: lint * chore: fix escape * chore: handle package overrides * chore: tweak * fix: fix script * fix: more imba * fix: --no-frozen-lockfile * fix: npm overrides * chore: run e2e * ci: fix ci * ci: typo * ci: fix cd? * ci: tweak * chore: simplify xvfb-run * test: use playwright assertion * chore: simplify xvfb-run * chore: readme
- Loading branch information
Showing
7 changed files
with
95 additions
and
24 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,46 @@ | ||
import process from 'node:process' | ||
import fs from 'node:fs' | ||
import { $ as $_ } from 'execa' | ||
|
||
const $ = $_({ stdio: 'inherit', verbose: true }) | ||
|
||
async function main() { | ||
// setup pakcage overrides for samples used by test-e2e | ||
const pkg = await readJson('package.json') | ||
if (pkg.pnpm?.overrides) { | ||
// pnpm | ||
await editJson('samples/e2e/package.json', (pkg2) => { | ||
pkg2.pnpm = pkg.pnpm | ||
return pkg2 | ||
}) | ||
await $({ cwd: 'samples/e2e' })`pnpm i --no-frozen-lockfile` | ||
|
||
// npm | ||
await editJson('samples/imba/package.json', (pkg2) => { | ||
pkg2.devDependencies.vitest = pkg.pnpm.overrides.vitest | ||
pkg2.overrides = pkg.pnpm.overrides | ||
return pkg2 | ||
}) | ||
await $({ cwd: 'samples/imba' })`npm i` | ||
} | ||
|
||
if (process.env.CI === 'true' && process.platform === 'linux') { | ||
await $`xvfb-run pnpm test` | ||
await $`xvfb-run pnpm test-e2e --retry 2` | ||
} | ||
else { | ||
await $`pnpm test` | ||
await $`pnpm test-e2e` | ||
} | ||
} | ||
|
||
async function readJson(file: string) { | ||
return JSON.parse(await fs.promises.readFile(file, 'utf-8')) | ||
} | ||
|
||
async function editJson(file: string, edit: (data: any) => any) { | ||
const data = await readJson(file) | ||
await fs.promises.writeFile(file, JSON.stringify(edit(data), null, 2)) | ||
} | ||
|
||
main() |
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,13 @@ | ||
# test-e2e | ||
|
||
To open playwright inspector, either run with `PWDEBUG` | ||
|
||
```sh | ||
PWDEBUG=1 pnpm test-e2e | ||
``` | ||
|
||
or use `page.pause` inside a test code | ||
|
||
```ts | ||
await page.pase() | ||
``` |
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