How to rerun parent spec when helper spec fails
Here is my small spec file that calls a helper file which contains all the it and describe block.
// File: externalAccountDirector.spec.js
const sharedTest = require('./permissions.shared');
sharedTest('externalAccountDirector');
When externalAccountDirector.spec.js fails, flake will try to rerun permissions.shared.js file instead. I would like to rerun externalAccountDirector.spec.js Thank you.
Can you give me a sample of what permissions.shared looks like (and example failure output)? I believe this is happening because the stack trace points to an exception thrown in that file and not the file that it is required in. There's no way to solve this at the moment.
I'm thinking about including a method to customize how exceptions are handled, so perhaps that might be a good fit for this (you would essentially
Here is the permissions.shared.js (sample structure)
function sharedPermissionTest(userRole) { const mediaPlanList = require('./../mediaPlans.po.js');
describe(
Media Plan Permissions Test, ()=> { it((setup) should get access token for internal system admin, (done) => { // Do some task expect().toBe(); done(); }); });module.exports = sharedPermissionTest;
The expect inside permissions.shared.js when failes causes this file to be re-run.
Output:
...
Ran 47 of 300 specs
47 specs, 1 failure
Finished in 71.693 seconds
Shutting down selenium standalone server.
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
Re-running tests: test attempt 3
Re-running the following test files:
/tests/new/pages/mediaPlans/permissions/permissions.shared.js
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://10.2.210.30:58674/wd/hub
Spec started
Started
Executed 0 of 0 specs SUCCESS in 0.001 sec.
No specs found
Finished in 0.003 seconds
Shutting down selenium standalone server.
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 passed
One idea I had was to re-run file with extension .spec.js.
This is also happening to me on Protractor 4.0.11.
Hmm, unfortunately given the way that stacktraces work there's no easy solve for this. The exception will be thrown in the spec that it was defined and that's what protractor flake will pick up on. Can you share the output of running the test without protractor flake?
I think an easier solution, would be to allow a "spec blacklist" file that one can pass as a parameter to protractor-flake. Protractor-flake would then parse each entry, create a pattern and if the pattern is matched, do not add the spec to the object for rerun.
blacklist.json
{
"blacklist" : [
"automation.js",
"multiPlatformTests.js",
"mobileTests.js",
"tophatTests.js",
"webTests.js"
]
}
Command Param:
protractor-flake --protractor-path=... --max-attempts=2 --spec-blacklist=/my/path/blacklist.json -- local_web.conf.js -s address