-1

I want to add a helper file for a global afterEach in my protractor conf file. But how do i load the file? I have tried like, but it does not work.

conf.ts

 mochaOpts: {
            file: './hooks.js',
            }
 }

hooks.ts

afterEach(async () => {
  console.log('---global after each');
});
user6086008
  • 101
  • 3
  • 14
  • 1
    not sure how mocha works but try `file: require('./hooks.js'),` – Sergey Pleshakov Sep 25 '19 at 23:14
  • Thanks, that worked to load the file. However I get error `afterEach is not defined`. So i guess the approach im using is not possible? How else would i get this global hook to run after every test spec, without having to include it in each test spec? – user6086008 Sep 26 '19 at 09:01

1 Answers1

0

So first problem is solved by requesting the file this way

file: require('./hooks.js')

For you next question see the discussion here for Jasmine How to reuse beforeEach/afterEach in Jasmine JS? I'm sure it's possible to do similar in Mocha

Sergey Pleshakov
  • 7,964
  • 2
  • 17
  • 40