为什么steps_file.js不实现I对象?

时间:2019-01-28 15:37:59

标签: javascript codeceptjs

运行测试时,我看到此错误:

  

登录类型的对象未在容器中定义

在include选项中设置的Steps文件。我该如何解决?

1_test.js

Feature('rer');

Scenario('test something', (I) => {
    I.amOnPage(url);
    I.see('E-mail');
    I.login('login', 'pas');
}

codecept.json

{
  "tests": "./*_test.js",
  "timeout": 10000,
  "output": "./output",
  "helpers": {
    "Puppeteer": {
      "url": "http://localhost",
      "fullPageScreenshots": true,
      "windowSize": "1920x1080"
    }
  },
  "include": {
    "I": "./steps_file.js"
  },
  "bootstrap": false,
  "mocha": {},
  "name": "nos.tests"
}

steps.js

'use strict';
// in this file you can append custom step methods to 'I' object

module.exports = function() {
  return actor({
    login: function  (login, password) {
      this.fillField('#email', login);
      this.fillField('#password', password);
      this.saveScreenshot('log.png');
      this.click('.btn-primary');
      this.wait(2);
    }
    // Define custom steps here, use 'this' to access default methods of I.
    // It is recommended to place a general 'login' function here.

  });
}

0 个答案:

没有答案