-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: main
Are you sure you want to change the base?
Conversation
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, | ||
}; | ||
}; |
There was a problem hiding this comment.
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
)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
createViemTest
to playwright report.Can be seen here:
