protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Don't prevent use of done in before and after functions

Open sgronblo opened this issue 12 years ago • 9 comments

I am attempting to use Jasmine's beforeEach on the describe level to reset my DB to a known good state for running tests.

There seems to be some action on behalf of Protractor to prevent users from doing this. Is it really necessary? It seems to prevent beforeEach and afterEach from doing anything asynchronous outside of WebDriver if I understand the implementation correctly.

If I comment out these two lines in protractor/jasminewd/index.js my tests pass.

global.beforeEach = wrapInControlFlow(global.beforeEach, 'beforeEach');
global.afterEach = wrapInControlFlow(global.afterEach, 'afterEach');

sgronblo avatar Apr 14 '14 03:04 sgronblo

We may be able to get around this by creating a new 'done' function which waits for both the WebDriver promises and any other promises to finish. Should investigate.

juliemr avatar Apr 14 '14 23:04 juliemr

Yeah I was thinking exactly the same.

sgronblo avatar Apr 15 '14 01:04 sgronblo

@hankduan this might be a fun one to take a look at!

juliemr avatar Apr 15 '14 03:04 juliemr

I guess this also means I can't do anything asynchronous in it calls either...

sgronblo avatar Apr 17 '14 02:04 sgronblo

I've fixed this here: https://github.com/angular/protractor/pull/728

hankduan avatar Apr 19 '14 00:04 hankduan

I have async call inside the "it" and that is never been executed. Can you point me what's wrong in the below code please?

describe('vCDBubble', function() { it('Check Org exists on the vCD', function(done) {

console.log("Ourside the async"); setTimeout(function(){ x = 1; console.log("Inside the async"); done(); }, 500); });

});

smahalingam avatar May 09 '14 17:05 smahalingam

The PR will be in the next release (May 24, 2014). You can use master if you need the code right now

hankduan avatar May 12 '14 20:05 hankduan

Yes i like to clone the master and do my work. Can you guide how to clone and install the master please ?

smahalingam avatar May 12 '14 20:05 smahalingam

Just a 'git clone https://github.com/angular/protractor.git' should do it Alternatively, you can apply the changes from jasminewd/index.js in https://github.com/angular/protractor/commit/43ff9e5e2a05b4e51d04133122d763ef4ed3f2d1 to the version you have temporarily to run your test

Whichever method you follow, you can just revert it once 0.23 gets released

hankduan avatar May 12 '14 20:05 hankduan