-
Notifications
You must be signed in to change notification settings - Fork 674
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
Ability to get screenshot path during test execution specified as pathPattern in settings #7864
Comments
I have a collection of undocumented TestCafe "functions". // testcafe-undocumented.ts
export const screenshotPath = (t: TestController): string => (t as any).testRun.opts.screenshots.path; Although they are undocumented and can change anytime - this did not change since TestCafe 1.x. |
@vasilyevi You can implement your own Reporter or wrap an existing one. The reporter plugin contains the reportTestDone method with the testRunInfo object argument. This object contains all captured screenshot paths. |
@Dmitry-Ostashev is it possible to get access to that object from after test? From “t” or other object? |
You cannot access this object from the test using |
@AlexKamaev I don't want to override the default reporter and implement own one, but I need the screenshots paths, what is the simplest way to get them? |
Alternatively, you can get your screenshot paths in reporter hook methods: https://testcafe.io/documentation/404388/guides/advanced-guides/modify-reporter-output. Here is a basic example for screenshots: function onBeforeWriteHook(writeInfo) {
if (writeInfo.initiator === 'reportTestDone')
writeInfo.formattedText += JSON.stringify(writeInfo.data.testRunInfo.screenshots.map(s => s.screenshotPath));
}
module.exports = {
hooks: {
reporter: {
onBeforeWrite: {
'spec': onBeforeWriteHook,
},
},
},
}; However, I still believe that you need to write your custom reporter to pass screenshots to your third-party service. |
What is your Scenario?
Trying to integrate autotests with 3rd party service(test reporting solution) and need to upload screenshot. Need to get an exact screenshot path in the end of each test. The pathPattern is the following
"${DATE}_${TIME}/${TEST}/${FILE_INDEX}_${QUARANTINE_ATTEMPT}.png"
What are you suggesting?
get from t?
What alternatives have you considered?
didn't find a good solution
Additional context
No response
The text was updated successfully, but these errors were encountered: