Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

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

Closed
sgronblo opened this issue Apr 14, 2014 · 9 comments
Closed

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

sgronblo opened this issue Apr 14, 2014 · 9 comments

Comments

@sgronblo
Copy link
Contributor

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');
@juliemr
Copy link
Member

juliemr commented Apr 14, 2014

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.

@sgronblo
Copy link
Contributor Author

Yeah I was thinking exactly the same.

@juliemr
Copy link
Member

juliemr commented Apr 15, 2014

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

@sgronblo
Copy link
Contributor Author

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

@hankduan
Copy link
Contributor

I've fixed this here: #728

@smahalingam
Copy link

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);
});

});

@hankduan
Copy link
Contributor

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

@smahalingam
Copy link

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

@hankduan
Copy link
Contributor

Just a 'git clone https://github.com/angular/protractor.git' should do it
Alternatively, you can apply the changes from jasminewd/index.js in 43ff9e5 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 hankduan removed their assignment Nov 4, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants