7

In Protractor, there is a "global set up" method called onPrepare(), but I'm not completely sure what is meant to be a "global tear down" - there are three relevant methods: onCleanUp, onComplete and afterLaunch that are all called after a test execution.

Why does protractor have three methods called after a test run? What is the difference between onCleanUp, onComplete and afterLaunch?


I've also noticed that there is an "exit" event that we can attach a callback to (example here):

protractor.on('exit', function (status) {

});
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195

1 Answers1

9

onComplete will be executed once per capability after all tests have finished, but the webdriver instance has not yet been shut down.

onCleanup will be executed once per capability after all tests have finished and the webdriver instance has been shut down

afterLaunch will be executed only once before program exits; after all capabilities are finished (after all onCleanup)

Further information on protractor callback functions can be found in their GitHub documentation.

Castro37
  • 3
  • 2
Johan Karlsson
  • 6,419
  • 1
  • 19
  • 28
  • 1
    Could you please add more details on which use cases each of the methods covers? Also, how does the "exit" event fit here? Thank you! – alecxe Dec 20 '15 at 02:51