setupAfterEach.js 991 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * Setup afterEach hook for jasmine/mocha tests.
  3. *
  4. * One of the main purposes of this file is to give `__protractor_internal_afterEach_setup_spec.js`
  5. * a place to look up `runner.afterEach` at runtime without using globals.
  6. * This file needs to be separate from `__protractor_internal_afterEach_setup_spec.js` so that that
  7. * file is not prematurely executed.
  8. */
  9. var path = require('path');
  10. // Queried by `protractor_internal_afterEach_setup_spec.js` for the `afterEach` hook
  11. var hooks = {
  12. afterEach: null
  13. };
  14. exports.hooks = hooks;
  15. /**
  16. * Setup `runner.afterEach` to be called after every spec.
  17. *
  18. * @param {Runner} runner The current Protractor Runner.
  19. * @param {Array} specs Array of Directory Path Strings. Must be a reference to the same array
  20. * instance used by the framework
  21. */
  22. exports.setup = function(runner, specs) {
  23. hooks.afterEach = runner.afterEach.bind(runner);
  24. specs.push(path.resolve(__dirname, '__protractor_internal_afterEach_setup_spec.js'));
  25. };