Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to attach anvil logs to playwright report #273

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

0xbulma
Copy link

@0xbulma 0xbulma commented Feb 27, 2025

  • add option to attach anvil logs in createViemTest to playwright report.

Can be seen here:
Screenshot 2025-02-27 at 15 15 15

@0xbulma 0xbulma self-assigned this Feb 27, 2025
@0xbulma 0xbulma requested a review from Rubilmax February 28, 2025 09:15
Comment on lines +10 to +31
const attachLogToPlaywright = (testInfo: TestInfo) => {
const anvilLogs: string[] = [];

const attachLog = (message: string) => {
anvilLogs.push(message);
};

const onClose = (message: string) => {
attachLog(message);

testInfo.attach("Anvil Logs", {
body: anvilLogs.join("\n"),
contentType: "text/plain",
});
};

return {
onMessage: attachLog,
onError: attachLog,
onClose: onClose,
};
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me this should be end user code because we're preventing devs from passing their own callbacks to createViemTest

I would simply expect the same optional argument callbacks?: AnvilProcessCallbacks

And for its vitest counterpart too! (also named createViemTest)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you think that making it native to your playwright wrapper is a good use case?
But happy to move it wherever you want or even outside of the repo.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can export the resulting object (the 3 callbacks) as a constant attachLogs from this file if you want! So you just have to pass it as the third optional parameter, in place of callbacks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants