Github user vladimir-kotikov commented on a diff in the pull request:

    
https://github.com/apache/cordova-plugin-camera/pull/177#discussion_r53838196
  
    --- Diff: appium-tests/android/android.spec.js ---
    @@ -295,13 +318,35 @@ describe('Camera tests Android.', function () {
                         .then(function () {
                             return driver; // no-op
                         }, function (error) {
    -                        expect(true).toFailWithMessage(error);
    +                        if (error.message.indexOf('Error response status: 
6') >= 0) {
    +                            // the session has expired but we can fix this!
    +                            console.log('The session has expired. Trying 
to start a new one...');
    +                            return getDriver();
    +                        } else {
    +                            expect(true).toFailWithMessage(error);
    +                        }
                         })
    -                    .execute('document.getElementById("info").innerHTML = 
"' + startingMessage + '";')
    +                    .execute('document.getElementById("info").innerHTML = 
"' + STARTING_MESSAGE + '";')
                         .finally(done);
                 }
                 done();
    -        }, 600000);
    +        }, 3 * MINUTE);
    +
    +        afterEach(function (done) {
    +            // recreate the session if there was a critical error in the 
spec
    +            if (stopFlag) {
    +                return driver
    --- End diff --
    
    This is not obvious that you're `return`'ing a promise here just to avoid 
second `done` call at the end of `afterEach`
    
    I'd recommend you to reverse `if` condition to enclose the shortest code 
path and reduce nesting, and to explicitly do a return after `done`. Something 
like:
    ```javascript
    if (!stopFlag) {
        done();
        return;
    }
    // promise chain here 
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to