Skip to content
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

How to rerun parent spec when helper spec fails #19

Open
prabinmetals opened this issue Mar 9, 2016 · 5 comments
Open

How to rerun parent spec when helper spec fails #19

prabinmetals opened this issue Mar 9, 2016 · 5 comments

Comments

@prabinmetals
Copy link

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.

@NickTomlin
Copy link
Owner

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

@prabinmetals
Copy link
Author

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.

@gologox
Copy link

gologox commented Nov 22, 2016

This is also happening to me on Protractor 4.0.11.

@NickTomlin
Copy link
Owner

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?

@gologox
Copy link

gologox commented Nov 22, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@NickTomlin @prabinmetals @gologox and others