From 88eae96f63b6e1371ec5606edd5a0c9ccaf9483e Mon Sep 17 00:00:00 2001 From: LingandRX Date: Mon, 17 Mar 2025 22:53:57 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=B6=88=E6=81=AF=E5=8F=91=E9=80=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=B9=B6=E8=B0=83=E6=95=B4=20trace=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 .gitlab-ci.yml 中添加 after_script 部分,根据测试结果发送相应消息 - 在 playwright.config.js 中将 trace 配置从 'retain-on-failure' 改为 'on',以收集所有测试的 trace 信息 --- .gitlab-ci.yml | 8 ++++++++ playwright.config.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2c191ff..9e54d4a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,6 +10,14 @@ playwright_tests: script: - npm install - npx playwright test /touch/boss_cashier.spec.ts --grep "挂单" --project '慧来客touch(管理员身份) - Desktop Chrome' + after_script: + - | + if [ "$CI_JOB_STATUS" == "success" ]; then + echo "Tests passed! Sending success message..." + else + echo "Tests failed! Sending failure message..." + node scripts/send-message.js "Some tests failed!" + fi artifacts: paths: - test-results/ diff --git a/playwright.config.js b/playwright.config.js index 2fa2f25..c59b2ff 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -55,7 +55,7 @@ module.exports = defineConfig({ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ hasTouch: true, - trace: 'retain-on-failure', + trace: 'on', screenshot: 'only-on-failure', timezoneId: 'Asia/Shanghai', locale: 'zh-CN',