javascript - יצוא testInfo.project.name של Playwright מחוץ ל-test.spec.ts


שלום, אני מנסה לקבל את הערך של testInfo.Project.Name שנוצר במהלך ביצוע מבחן (ב־test.spec.ts) ולייצא אותו לשימוש במודול אחר (למשל customReport.js). ניסיתי כמה דברים אבל אף אחד מהם לא עבד.

מה שניסיתי ב-customReport.js:

  1. var _globals=require("../node_modules/@playwright/test/lib/globals") תוצאה: תיקיית lib לא קיימת בנתיב הזה.

  2. var _globals=require("../node_modules/playwright/lib/common/globals.js") תוצאה: לוג הקונסול מחזיר undefined.

  3. מוצהר

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