protractor icon indicating copy to clipboard operation
protractor copied to clipboard

setup and teardown methods at class/file level

Open vishalshivnath opened this issue 13 years ago • 19 comments

Do we have setup and teardown methods at class/file level. beforeEach and afterEach runs before and after each test case. Do we have setup and teardown at class level

vishalshivnath avatar Sep 23 '13 15:09 vishalshivnath

@vishalshivnath, you can use afterAll. You can see example here https://github.com/angular/protractor/blob/master/example/onJasmineNodeSpec.js

apankov1 avatar Sep 23 '13 17:09 apankov1

Unfortunately, beforeAll and afterAll aren't supported by Jasmine, JasmineNode, or MiniJasmineNode. You can achieve the effect by relying on the fact that it specs run in order, but it's a hack.

Depending on what Jasmine 1.2's take is on the matter, we should consider adding this to MiniJasmineNode.

Note that you can do global setup/teardown via the config file with onPrepare and jasmineNodeOpts.onComplete. See https://github.com/angular/protractor/blob/master/referenceConf.js#L65

juliemr avatar Sep 24 '13 00:09 juliemr

Thats helpful thanks

vishalshivnath avatar Sep 24 '13 07:09 vishalshivnath

Jasmine has added support for beforeAll and afterAll in this https://github.com/pivotal/jasmine/commit/ba0982d89f6d2a6523e505f062638a708ac0c25e commit as of 15 days ago.

Any chance we can get an updated version of protractor with this patch? This would be huge for us right now.

Thanks.

agentHoover avatar Oct 09 '14 22:10 agentHoover

It would be extremely helpful to have beforeAll and afterAll!

rns4731 avatar Oct 14 '14 21:10 rns4731

Please?

clydet avatar Oct 24 '14 16:10 clydet

Right now protractor only supports jasmine 1.3 (see https://github.com/angular/protractor/issues/362 and https://github.com/angular/jasminewd/pull/5). Moving to 2.0 is definitely on the to-do list. Please add to that issue about this.

hankduan avatar Oct 27 '14 21:10 hankduan

+1

diaakasem avatar Dec 13 '14 07:12 diaakasem

Hi, all

I managed to create a custom beforeAll method which works (I guess) the same as it was supposed to. I'm currently using it as a helper in my tests, and it seems to work properly until now. Any help is appreciated.

You can find the helper code on the following gist: https://gist.github.com/lucasconstantino/269e24094898832068f3

lucasconstantino avatar Dec 17 '14 18:12 lucasconstantino

+1 thanks a bunch @lucasconstantino

dandoyon avatar Jan 06 '15 23:01 dandoyon

Note that with 1.6.0 you will be able to use jasmine2 with protractor. There you can use beforeAll/afterAll

hankduan avatar Jan 07 '15 00:01 hankduan

Hi, What is the latest news about beforeAll/afterAll with protractor?

ramkatwix avatar Jan 12 '15 11:01 ramkatwix

1.6.0 has been released - you may now use framework: jamsine2, which allows the use of beforeAll and afterAll

juliemr avatar Jan 12 '15 19:01 juliemr

beforeAll and afterAll work like a charm in 1.6.0, Thanks guys!

americos avatar Jan 20 '15 20:01 americos

Please help me, What am I doing wrong?

protractor --version
Version 1.6.1 
Message:
  ReferenceError: afterAll is not defined
Stacktrace:
  ReferenceError: afterAll is not defined
   [chrome #2]     at [object Object].jasmine.Env.describe_ (\node_modules\minijasminenode\lib\jasmine-1.3
.1.js:913:21)

extdevelopment avatar Feb 02 '15 18:02 extdevelopment

@extdevelopment I think that error happens when you don't specify jasmine2 inside protractor.conf.js make sure you add this line: framework: jasmine2 to your protractor.conf.js

americos avatar Feb 02 '15 18:02 americos

@americos thx framework: 'jasmine2' helped

extdevelopment avatar Feb 02 '15 19:02 extdevelopment

After adding framework: 'jasmine2' I get the following error when trying to use ddescribe at the root of my test file:

launcher] Error: ReferenceError: ddescribe is not defined

Furthermore, ddescribe and iit take no effect inside the test suite.

ljwagerfield avatar Feb 12 '15 17:02 ljwagerfield

@ljwagerfield Please read the upgrade guide. https://github.com/angular/protractor/blob/master/docs/jasmine-upgrade.md#focused-specs

ddescribe and iit -> fdescribe, fit

hankduan avatar Feb 12 '15 19:02 hankduan