Skip to content

Commit

Permalink
test: fix getting all files in testdir helper
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Sep 26, 2024
1 parent 37e2fb4 commit d18c7d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions test/_helpers/TestDir.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions test/reporter-cucumber-ext-attachments/test.mjs
Original file line number Diff line number Diff line change
@@ -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);

Expand All @@ -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']);
Expand Down

0 comments on commit d18c7d6

Please sign in to comment.