diff --git a/test/_helpers/TestDir.mjs b/test/_helpers/TestDir.mjs index bdc790c7..145f8033 100644 --- a/test/_helpers/TestDir.mjs +++ b/test/_helpers/TestDir.mjs @@ -4,6 +4,7 @@ import assert from 'node:assert/strict'; import path from 'node:path'; import fs from 'node:fs'; +import fg from 'fast-glob'; import { fileURLToPath } from 'node:url'; import { expect } from '@playwright/test'; @@ -40,6 +41,11 @@ export class TestDir { return fs.readFileSync(absPath, 'utf8'); } + getAllFiles(relativePath) { + const cwd = this.getAbsPath(relativePath); + return fg.sync('**', { cwd }); + } + expectFileContains(relativePath, substr) { const substrList = Array.isArray(substr) ? substr : [substr]; const fileContents = this.getFileContents(relativePath); diff --git a/test/reporter-cucumber-ext-attachments/test.mjs b/test/reporter-cucumber-ext-attachments/test.mjs index 73fcb6d5..4bb35e9b 100644 --- a/test/reporter-cucumber-ext-attachments/test.mjs +++ b/test/reporter-cucumber-ext-attachments/test.mjs @@ -1,6 +1,5 @@ import { test, expect, TestDir, execPlaywrightTest } from '../_helpers/index.mjs'; import path from 'node:path'; -import fg from 'fast-glob'; const testDir = new TestDir(import.meta); @@ -23,8 +22,8 @@ function checkHtmlReport() { } function checkAttachmentFiles() { - const extensions = fg - .sync('actual-reports/attachments/*', { cwd: path.dirname(testDir.getAbsPath()) }) + const extensions = testDir + .getAllFiles('actual-reports/attachments') .map((file) => path.extname(file)) .sort(); expect(extensions).toEqual(['.png', '.png', '.webm', '.zip']);