Using require with relative paths

前端 未结 4 1020
灰色年华
灰色年华 2020-11-27 16:41

We have a rather big set of end-to-end tests on Protractor. We are following the Page Object pattern which helps us to keep our tests clean and modular. We also have a set o

4条回答
  •  青春惊慌失措
    2020-11-27 17:34

    I have had the same issue. Did similar solution to Michael Radionov's, but not setting a global function, but setting a property to protractor itself.

    protractor.conf.js

    onPrepare: function() {
      protractor.basePath = __dirname;
    }
    

    test-e2e.js

    require(protractor.basePath+'/helpers.js');
    
    describe('test', function() {
       .......
    });
    

提交回复
热议问题