更新 CI 工作流以使用新的容器,修改 Playwright 基础 URL,增强测试用例以附加截图和日志
This commit is contained in:
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
@ -29,14 +29,16 @@ jobs:
|
|||||||
- name: 部署到 Vercel
|
- name: 部署到 Vercel
|
||||||
run: pnpm exec vercel deploy --prebuilt --target=production --token=${{ secrets.VERCEL_TOKEN }}
|
run: pnpm exec vercel deploy --prebuilt --target=production --token=${{ secrets.VERCEL_TOKEN }}
|
||||||
|
|
||||||
playwright:
|
playwright: # act --job playwright --workflows .github/workflows/ci.yaml --pull=false --dryrun
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container: yanhao98/runner-images:pnpm-with-playwright
|
||||||
steps:
|
steps:
|
||||||
- uses: yanhao98/composite-actions/setup-node-environment@main
|
- uses: yanhao98/composite-actions/setup-node-environment@main
|
||||||
- run: pnpm run build-only
|
- run: pnpm run build-only
|
||||||
env:
|
env:
|
||||||
VITE_BUILD_COMMIT: ${{ github.sha }}
|
VITE_BUILD_COMMIT: ${{ github.sha }}
|
||||||
- name: 部署到 Surge
|
- name: 部署到 Surge
|
||||||
|
if: ${{ !env.ACT }} # https://nektosact.com/usage/index.html#skipping-steps
|
||||||
id: surge_deploy
|
id: surge_deploy
|
||||||
# pnpm exec surge token / pnpx surge token
|
# pnpm exec surge token / pnpx surge token
|
||||||
# https://github.com/Tencent/tdesign-vue-next/pull/1604#issuecomment-1236244550
|
# https://github.com/Tencent/tdesign-vue-next/pull/1604#issuecomment-1236244550
|
||||||
|
@ -26,7 +26,7 @@ export default defineConfig({
|
|||||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||||
use: {
|
use: {
|
||||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||||
baseURL: process.env.BASE_URL || 'https://vue-ts-example.surge.sh',
|
baseURL: process.env.BASE_URL || 'https://vue-ts-example.oo1.dev',
|
||||||
|
|
||||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
trace: 'on-first-retry',
|
trace: 'on-first-retry',
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
test('页面加载正常', async ({ page }) => {
|
test('页面加载正常', async ({ page }, testInfo) => {
|
||||||
await page.goto('/');
|
await page.goto('/');
|
||||||
console.log(page.url());
|
console.log(`page.url() === ${page.url()}`);
|
||||||
await expect(page.getByRole('link', { name: '中文-页面.page.vue' })).toBeVisible();
|
await expect(page.getByRole('link', { name: '中文-页面.page.vue' })).toBeVisible();
|
||||||
|
await testInfo.attach('screenshot', { body: await page.screenshot({ fullPage: true }), contentType: 'image/png' });
|
||||||
|
|
||||||
|
// 使用文本选择器查找包含 "commit:" 的元素
|
||||||
|
const commitElement = page.locator('text=commit:').first();
|
||||||
|
const innerText = await commitElement.innerText();
|
||||||
|
console.log(`Commit 文本内容: "${innerText}"`);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user