Skip to content

Commit

Permalink
fix problem when pw test utils reads directory in the generated test …
Browse files Browse the repository at this point in the history
…fixtures
  • Loading branch information
epszaw committed Feb 13, 2025
1 parent 1d3d52a commit 266acbd
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
14 changes: 14 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
1 change: 1 addition & 0 deletions packages/allure-playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"eslint-plugin-n": "^17.10.1",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"glob": "^11.0.1",
"npm-run-all2": "^7.0.0",
"rimraf": "^6.0.0",
"typescript": "^5.2.2",
Expand Down
13 changes: 7 additions & 6 deletions packages/allure-playwright/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { fork } from "child_process";
import { glob } from "glob";
import { randomUUID } from "node:crypto";
import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
import { dirname, extname, join } from "node:path";
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
import { dirname, extname, join, relative } from "node:path";
import { attachment, logStep, step } from "allure-js-commons";
import type { AllureResults } from "allure-js-commons/sdk";
import { MessageReader } from "allure-js-commons/sdk/reporter";
Expand Down Expand Up @@ -86,7 +87,9 @@ export const runPlaywrightInlineTest = async (

return new Promise((resolve) => {
testProcess.on("exit", async (code, signal) => {
const resultsFiles = (await readdir(testDir)).filter((filename) => !testFilesNames.includes(filename));
const resultsFiles = (await glob(join(testDir, "**/*"), { nodir: true }))
.map((filename) => relative(testDir, filename))
.filter((filename) => !testFilesNames.includes(filename));

if (signal) {
await logStep(`Interrupted with ${signal}`);
Expand All @@ -105,9 +108,7 @@ export const runPlaywrightInlineTest = async (
};

for (const file of resultsFiles) {
const content = await readFile(join(testDir, file), "utf-8");

result.restFiles[file] = content;
result.restFiles[file] = await readFile(join(testDir, file), "utf-8");
}

await rm(testDir, { recursive: true });
Expand Down
17 changes: 17 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5837,6 +5837,7 @@ __metadata:
eslint-plugin-n: "npm:^17.10.1"
eslint-plugin-no-null: "npm:^1.0.2"
eslint-plugin-prefer-arrow: "npm:^1.2.3"
glob: "npm:^11.0.1"
npm-run-all2: "npm:^7.0.0"
rimraf: "npm:^6.0.0"
typescript: "npm:^5.2.2"
Expand Down Expand Up @@ -9939,6 +9940,22 @@ __metadata:
languageName: node
linkType: hard

"glob@npm:^11.0.1":
version: 11.0.1
resolution: "glob@npm:11.0.1"
dependencies:
foreground-child: "npm:^3.1.0"
jackspeak: "npm:^4.0.1"
minimatch: "npm:^10.0.0"
minipass: "npm:^7.1.2"
package-json-from-dist: "npm:^1.0.0"
path-scurry: "npm:^2.0.0"
bin:
glob: dist/esm/bin.mjs
checksum: 10/57b12a05cc25f1c38f3b24cf6ea7a8bacef11e782c4b9a8c5b0bef3e6c5bcb8c4548cb31eb4115592e0490a024c1bde7359c470565608dd061d3b21179740457
languageName: node
linkType: hard

"glob@npm:^6.0.1":
version: 6.0.4
resolution: "glob@npm:6.0.4"
Expand Down

0 comments on commit 266acbd

Please sign in to comment.