archfz/cypress-terminal-report

Writing to file doesn't fully work with cypress-fail-fast

anshap1719 opened this issue · 7 comments

Hello,

We have a custom parallel running setup using Cypress' Module API and custom node script that takes care of launching parallel instances and combining and generating reports at the end. Although the error described below is reproducible even without parallel builds.

Current behaviour

When using cypress-fail-fast, if one of the it blocks fail in a spec file, the rest are skipped. The spec output log file isn't being generated in this particular case. It only gets generated if either fail fast is disabled or the spec file has only 1 it block or the error is in last it block (so that no other it block from same spec file gets skipped).

Expected behaviour

The log files should be created whether or not tests are being skipped if at least one of the it blocks ran in a spec file.

Plugin config

    require('cypress-terminal-report/src/installLogsPrinter')(on, {
        printLogsToConsole: process.env.NO_LOGS === '1' ? 'never' : 'onFail',
        printLogsToFile: 'always',
        outputRoot: path.resolve(__dirname, '..', 'logs'),
        specRoot: path.relative(config.fileServerFolder, config.integrationFolder),
        outputTarget: {
            '.|json': 'json',
        }
    });

I don't know of a way to modify this behaviour, and collectTestLogs doesn't fit our use case as we attach the files to our Jenkins artifacts.

Is there a way to solve this without using collectTestLogs?

Well currently we output to files in an after hook so need to see why that hook doesn't execute in this case.

Thanks for the quick reply. I'll see if fail fast has any such configuration as well then.

@archfz So it turns out, cypress-fail-fast skips the tests using the before hook. Which could explain why the after hook doesn't run. And this is not configurable, so maybe it's an issue with that plugin instead of this one. If you feel the same, feel free to close the issue.

Yeah its an issue on our side. Contribution is welcome.

@archfz I think the best way forward with this is to wait for cypress' new hooks ("after:spec") to be out of experimental events and use it instead.

Support introduced in 3.2.0. Read changelog to see how to enable.

Thank You!