量角器-茉莉花TypeError:无法读取未定义的属性'结果'

时间:2020-04-10 07:52:42

标签: jasmine protractor

最近,每当我尝试远程执行量角器测试时,我都会遇到以下问题。

我在执行时收到错误消息:

 npm run e2e:remote

> hogs@0.1.22 e2e:remote /home/user/projects/project
> ./node_modules/protractor/bin/protractor e2e/protractor.remote.conf.js

[09:34:07] I/launcher - Running 1 instances of WebDriver
[09:34:07] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
Jasmine started

/home/user/projects/project/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:5120 返回儿童&&儿童[0] .result.status; ^

TypeError: Cannot read property 'result' of undefined
    at isAfterAll (/home/user/projects/project/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:5120:36)
    at Suite.onException (/home/user/projects/project/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:5083:8)
    at Suite.onException (/home/user/projects/project/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:5095:27)
    at QueueRunner.onException (/home/user/projects/project/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:5191:28)
    at onException (/home/user/projects/project/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:4310:14)
    at handleError (/home/user/projects/project/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:4243:11)
    at process.onerror (/home/user/projects/project/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:2371:17)
    at process.emit (events.js:223:5)
    at process.emit (/home/user/projects/project/node_modules/protractor/node_modules/source-map-support/source-map-support.js:439:21)
    at process.emit (/home/user/projects/project/node_modules/source-map-support/source-map-support.js:485:21)

由于上述原因,我根本无法远程运行测试。

我的protractor.conf.js:

    require('dotenv').config();

const { SpecReporter } = require('jasmine-spec-reporter');

/**
 * @type { import("protractor").Config }
 */
exports.config = {
  seleniumAddress: process.env.SELENIUM_SERVER_ADDRESS || `http://localhost:4444/wd/hub`,
  allScriptsTimeout: 11000,
  specs: ['./src/**/*.e2e-spec.ts'],
  // directConnect: true,
  multiCapabilities: [
    {
      browserName: 'chrome',
      shardTestFiles: false,
      maxInstances: 2,
    },
    //{
    // browserName: 'firefox',
    //},
  ],
  maxSessions: -1,
  baseUrl: process.env.REMOTE_URL || "",
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {},
  },
  onPrepare() {
    process.env.USER_EMAIL = process.env.USER_EMAIL || '';
    process.env.USER_PASSWORD = process.env.USER_PASSWORD || '';

    require('ts-node').register({
      project: 'e2e/tsconfig.json',
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  },
};

当我取消对directconnect的注释时,测试运行平稳,尽管在我们的项目中,我们应该通过硒网格运行测试,所以没有它的远程运行至关重要。

茉莉花版本是3.5.0, 量角器是5.4.3版。

0 个答案:

没有答案