Search code examples
testingconfigurationautomated-testse2e-testingtestcafe

Issues with video path


TestCafe doesn't recognize ${TEST} for video path.

I'm trying to implement test recording for failed tests in order to see how we could replicate the appeared problem, but the video path isn't recognized even though a similar path pattern works for screenshots.

According to the documentation, this should work but the following warning is displayed:

Warnings (1):

The "${TEST}" path pattern placeholder cannot be applied to the recorded video.

The placeholder was replaced with an empty string.

I created TestRunner.js as shown in https://devexpress.github.io/testcafe/documentation/using-testcafe/programming-interface/runner.html. Then I added

if(runnerOptions.takeVideo === true && runInParallel === 1) {
    runner.video(reports.videoPath, {
        singleFile: true,
        failedOnly: true,
        pathPattern: store + '-' + env + '/${TEST}/${DATE}_${TIME}/${USERAGENT}'
    })
}

return runner
    .src(tests)
    .browsers(config.browsers)
    .screenshots(reports.screenshotPath, runnerOptions.takeScreenshots,
         store + '-' + env + '/${TEST}/${DATE}_${TIME}/${RUN_ID}/${USERAGENT}/step-${FILE_INDEX}')
    .concurrency(runInParallel)
    .run(runnerOptions.run);

As I said screenshots work fine, but videos don't.


Solution

  • According to this GitHub issue, specifying singleFile: true is the cause. When saving all the failed tests into one recording, the path pattern can't use a single test or fixture identifier to name the file.

    The following pattern placeholders resolve to an empty string with a single file:

    • ${TEST_ID}
    • ${TEST_INDEX}
    • ${FIXTURE}
    • ${TEST}
    • ${TEST_ID}

    The documentation for the path patterns does mention this restriction for single files, but only in reference to ${TEST_ID} and not the other placeholders.