Open vdimikj opened 6 years ago
Unfortunately this is not possible without using a custom reporter; the stacktraces for timeouts don't include the path to the source spec in them if I remember correctly.
You could write your own reporter that prints the spec files out and then checks for failures and then write a custom protractor flake parser.
There's a feature request here https://github.com/NickTomlin/protractor-flake/issues/72 that goes over things.
I'd love to see this implemented and then pull requested if you have time!
@vdimikj: If you set shardTestFiles
to true in protractor.conf.js and use the multi parser, you won't have this issue. Protractor logs "Specs: <(specs-to-be-executed)>" for each browser instance by default, and the parser will identify the specs with Jasmine timeout errors.
If you must execute sequentially, you can try implementing the following:
In your protractor config, get Protractor's logger & CLI args:
const cliArgs = require('yargs').argv,
Logger = require('protractor/built/logger').Logger,
logger = new Logger('JasmineFailLogger');
Add the onPrepare()
hook to your config, and include the following:
onPrepare: () => {
const jasmineEnv = jasmine.getEnv();
// Hacky workaround for https://github.com/NickTomlin/protractor-flake/issues/83
jasmineEnv.addReporter({
specDone: (result) => {
if (result.status === 'failed' && result.failedExpectations[0].message.startsWith('Error: ')) {
const specName = result.fullName.replace(/ .*/, '');
const cliArgSpecs = cliArgs.specs.split(',');
const failedSpecPath = cliArgSpecs.filter(spec => spec.includes(specName));
// Log this the same way protractor logs sequential specs so the parser finds it
logger.info(`A Jasmine error occured at UserContext.it (${failedSpecPath.toString()}:)`);
}
}
}
);
},
Hi there!
When test fail due to
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Protractor-flake fails to parse the failing test and the spec is not rerun thus failing to "rerun potentially flakey protractor tests before failing."For better recreation I have setup an example found on git-url .