Skip to content

Commit

Permalink
chore: tiny fixes in typings and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Oct 10, 2024
1 parent 6ec59a1 commit d6938e2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/basic-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "commonjs",
"scripts": {
"test": "npx bddgen && npx playwright test",
"show-report": "npx http-server ./cucumber-report -o index.html",
"show-report": "npx http-server ./cucumber-report -c-1 -o index.html",
"watch:bdd": "nodemon -w ./features -w ./steps -e feature,js,ts --exec \"npx bddgen\"",
"watch:pw": "playwright test --ui",
"watch": "run-p watch:*"
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"type": "module",
"scripts": {
"test": "npx bddgen && npx playwright test",
"show-report": "npx http-server ./cucumber-report -o index.html"
"show-report": "npx http-server ./cucumber-report -c-1 -o index.html"
}
}
17 changes: 2 additions & 15 deletions src/reporter/cucumber/attachments/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export function toExternalAttachment(
const fileName = calculateSha1(buffer) + '.' + extension;
const filePath = path.join(attachmentsDir, fileName);
// todo: save file async?
fs.writeFileSync(filePath, buffer);
// without converting to Uint8Array TS complains about buffer type
fs.writeFileSync(filePath, new Uint8Array(buffer));

return {
...attachment,
Expand All @@ -72,17 +73,3 @@ function getAttachmentExtension(attachment: messages.Attachment) {
export function isTextAttachment(attachment: messages.Attachment) {
return /^(text\/|application\/json)/.test(attachment.mediaType);
}

// function createMissingAttachmentError(attachmentPath: string) {
// const attachmentDir = path.join(path.dirname(attachmentPath));
// const attachmentDirExists = fs.existsSync(attachmentDir);
// const files = attachmentDirExists ? fs.readdirSync(attachmentDir) : [];
// const errorMsg = [
// `Attachment file is not found:`,
// attachmentPath,
// `Attachment dir ${attachmentDirExists ? 'exists' : 'does not exist'}.`,
// ...(attachmentDirExists ? [`Available files (${files.length}):`, ...files] : []),
// '',
// ].join('\n');
// return new Error(errorMsg);
// }
2 changes: 2 additions & 0 deletions src/reporter/cucumber/attachments/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ export function isTraceAttachment(attachment: messages.Attachment) {
}

export function generateTraceUrl(attachment: messages.Attachment) {
// In PW trace url is generated dynamically in JS with location.href:
// https://github.com/microsoft/playwright/blob/8f3353865d8d98e9b40c15497e60d5e2583410b6/packages/html-reporter/src/links.tsx#L102
return `trace/index.html?trace=${attachment.url}`;
}

0 comments on commit d6938e2

Please sign in to comment.