javascript - ส่งออก Playwright testInfo.project.name ภายนอกไฟล์ test.spec.ts
สวัสดี ฉันกำลังพยายามดึงค่าของ testInfo.Project.Name ที่ถูกสร้างขึ้นระหว่างการรันเทสต์ (ใน test.spec.ts) และส่งออกเพื่อใช้งานในโมดูลอื่น (เช่น customReport.js) ฉันได้ลองทำหลายวิธีแล้วแต่ไม่มีวิธีไหนที่ใช้ได้ผล
สิ่งที่ฉันได้ลองใน customReport.js:
var _globals=require("../node_modules/@playwright/test/lib/globals")ผลลัพธ์: โฟลเดอร์ lib ไม่มีอยู่ในเส้นทางนั้นvar _globals=require("../node_modules/playwright/lib/common/globals.js")ผลลัพธ์: การแสดงผล console log คืนค่า undefined.ประกาศ
var projectDetail = {browser: ''} export {projectDetail} in customReport.js
import { projectDetail } from './customReport.js' in test.spec.ts
test('sample', async ({page}, testInfo) => {packageDetail.browse = testInfo.project.name});
ผลลัพธ์ : console log คืนค่า undefined ในไฟล์ customReport.js