webdriverio-boneyard / wdio-jasmine-framework

A WebdriverIO v4 plugin. Adapter for Jasmine testing framework.
http://webdriver.io/
MIT License
23 stars 23 forks source link

Failing test to capture problem with it blocks not resolving promises #14

Closed kurtharriger closed 8 years ago

kurtharriger commented 8 years ago

Here is a failing test for issue https://github.com/webdriverio/wdio-jasmine-framework/issues/13.

I figured out why your test was passing and mine was not.

Promises returned by the it block are not being waited on, but because you have an afterEach block that also waits the promise has sufficient time to resolve before the test is completed.

The key difference I think is that in jasmine a function is executed in async mode only when the provided function has argument length 1. If the function provided takes no arguments, jasmine assumes the test is synchronous does not provide a done function and thus does not wait for it to be called.

This is the only occurrence in wdio-sync where origFn is called using a function with 0 arguments and thus explains why there is different behavior for it/fit blocks then before/after* blocks.

https://github.com/webdriverio/wdio-sync/blob/master/index.js#L476

I can reproduce the failure in the wdio-jasmine-framework tests by simply making the timeout for the it block longer than the timeout for the afterEach block.

kurtharriger commented 8 years ago

I thought I had reproduced it by increasing the timeout, but in my removing and adding things I put the timeout in the wrong test so it failed for the wrong reason.
The problem still exists its just harder verify as the test will pass providing an afterAll/afterEach exists, so I updated this failing example by commenting out the afterAll/afterEach. Not ideal as we still want to test those functions, but this reproduces the error anyway.

kurtharriger commented 8 years ago

Cleaned up the test so that its no longer necessary to comment out after* methods to reproduce the failure by creating additional specs for this behavior.

This can be merged after https://github.com/webdriverio/wdio-sync/pull/34 has been merged and updated.

christian-bromann commented 8 years ago

@kurtharriger could you please bump the wdio-sync version to v0.5.3 and rerun the build?

kurtharriger commented 8 years ago

Updated.
I also added an additional test for https://github.com/webdriverio/webdriverio/issues/1278

christian-bromann commented 8 years ago

Awesome thanks! Is this PR ready to get merged now?

kurtharriger commented 8 years ago

Yes

christian-bromann commented 8 years ago

@kurtharriger thanks for the tests and the wdio-sync fix