senthanal / gulp-jasmine-webdriverio

gulp-jasmine-webdriverio is a Gulp plugin to run Selenium tests with Jasmine and WebdriverIO
MIT License
6 stars 4 forks source link

Syntax error in WebDriverIo callback causes selenium processes to be left running #1

Open jaredbro opened 9 years ago

jaredbro commented 9 years ago

i'm trying to switch from using webdriverio with gulp to using jasmine. I really like how easy this plugin works, but I've run into an odd problem that can cause a lot of frustration in the development cycle. If you have a syntax error in a webdriver.io callback (see example below), this plugin will cause gulp to just error out and never cleanup any server resources or allow subsequent tasks to not be executed. I have noticed that the gulp-webdriver plugin does handle this correctly.

To reproduce, change test.js to be the following:

describe('gulp-jasmine-webdriverio test', function () {
    it('checks if title contains the search query', function(done) {
        browser
            .url('https://github.com/senthanal/gulp-jasmine-webdriverio')
            .getTitle(function(err,title) {
                exxxxxxxpect(title).toEqual('senthanal/gulp-jasmine-webdriverio · GitHub');
            })
            .call(done);
    });

});

Then run, and you'll see the following error results:

[09:44:20]:  RESULT      {"applicationCacheEnabled":false,"rotatable":false,"mobileEmulationEnabled":false,"chrome":{"userDataDir":"/var/folders/rc/0r5nsf9j03b1shybxsngdm580000gp/T/.org.chromium.Chromium.Xe3Gi9"},"takesHeapSnapshot":true,"databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":false,"version":"43.0.2357.132","platform":"MAC","browserConnectionEnabled":false,"nativeEvents":true,"acceptSslCerts":true,"webdriver.remote.sessionid":"24e1ee0f-de63-4936-b91e-a5e4ee4509ed","locationContextEnabled":true,"webStorageEnabled":true,"browserName":"chrome","takesScreenshot":true,"javascriptEnabled":true,"cssSelectorsEnabled":true}
[09:44:20] run jasmine tests
[09:44:20]:  COMMAND    POST     "/wd/hub/session/24e1ee0f-de63-4936-b91e-a5e4ee4509ed/url"
[09:44:20]:  DATA        {"url":"https://github.com/senthanal/gulp-jasmine-webdriverio"}
[09:44:22]:  COMMAND    GET      "/wd/hub/session/24e1ee0f-de63-4936-b91e-a5e4ee4509ed/title"
[09:44:22]:  DATA        {}
[09:44:22]:  RESULT      senthanal/gulp-jasmine-webdriverio · GitHub
/Users//projects/github/gulp-jasmine-webdriverio/usecases/test.js:6
                exxpect(title).toEqual('senthanal/gulp-jasmine-webdriverio · G
                ^
ReferenceError: exxpect is not defined
    at WebdriverIO.<anonymous> (/Users/projects/github/gulp-jasmine-webdriverio/usecases/test.js:6:17)
    at WebdriverIO.<anonymous> (/Users/projects/github/gulp-jasmine-webdriverio/node_modules/webdriverio/lib/utils/PromiseHandler.js:152:26)
    at /Users/projects/github/gulp-jasmine-webdriverio/node_modules/webdriverio/node_modules/chainit/index.js:137:22
    at /Users/projects/github/gulp-jasmine-webdriverio/node_modules/webdriverio/lib/commands/getTitle.js:43:9
    at /Users/projects/github/gulp-jasmine-webdriverio/node_modules/webdriverio/lib/commands/getTitle.js:39:13
    at fn (/Users/projects/github/gulp-jasmine-webdriverio/node_modules/async/lib/async.js:638:34)
    at Immediate._onImmediate (/Users/projects/github/gulp-jasmine-webdriverio/node_modules/async/lib/async.js:554:34)
    at processImmediate [as _immediateCallback] (timers.js:358:17)

Any suggestions for how to fix this?

senthanal commented 9 years ago

Hi, I was in holidays, couldn't reply earlier. By the way, thanks for the detailed error report. I've reproduced error. Seems internal issue with jamine, see here https://github.com/jasmine/jasmine/pull/179. As per ther thread only way to handle such syntax errors by linting test code. Hmm, ofcourse is not enough. I don't think we have an easy solution here... What do you think?