当jasmine-spec-reporter

时间:2017-09-15 14:58:37

标签: jasmine protractor e2e-testing jasmine-spec-reporter

我的配置:

  • Windows 10
  • npm 5.3.0
  • node v8.4.0
  • jasmine 2.8.0
  • jasmine-spec-reporter 4.2.1
  • 量角器5.1.2

以前我使用标准茉莉花记录器进行E2E测试输出。 最近我安装了jasmine-spec-reporter,输出看起来更好。 但是现在我在TeamCity中遇到了问题。 在TeamCity中执行测试之后,即使某些测试失败,我总是“使用代码0退出进程”。 使用标准记录器,我没有遇到这样的问题。 你能否建议如何解决这个问题。

TeamCity输出:

I/launcher - Running 1 instances of WebDriver
I/direct - Using ChromeDriver directly...
Jasmine started

  1 LoginComponent
    x should set focus to the Password field after incorrect password has been entered
      - Expected false to be truthy.
          at Function.CustomMatchers.expectToBeFocused (D:\TeamCity\BuildAgent\work\e2eng2\ng2\e2e\matchers\custom-matchers.ts:13:6)
          at UserContext.<anonymous> (D:\TeamCity\BuildAgent\work\e2eng2\ng2\e2e\tests\login.e2e.ts:53:18)
          at new ManagedPromise (D:\TeamCity\BuildAgent\work\e2eng2\ng2\node_modules\selenium-webdriver\lib\promise.js:1067:7)
          at ControlFlow.promise (D:\TeamCity\BuildAgent\work\e2eng2\ng2\node_modules\selenium-webdriver\lib\promise.js:2396:12)
          at TaskQueue.execute_ (D:\TeamCity\BuildAgent\work\e2eng2\ng2\node_modules\selenium-webdriver\lib\promise.js:2970:14)
          at TaskQueue.executeNext_ (D:\TeamCity\BuildAgent\work\e2eng2\ng2\node_modules\selenium-webdriver\lib\promise.js:2953:27)
          at asyncRun (D:\TeamCity\BuildAgent\work\e2eng2\ng2\node_modules\selenium-webdriver\lib\promise.js:2860:25)

**************************************************
*                    Failures                    *
**************************************************

1) LoginComponent should set focus to the Password field after incorrect password has been entered
  - Expected false to be truthy.

Executed 1 of 9 specs (1 FAILED) (8 SKIPPED) in 10 secs.
I/launcher - 0 instance(s) of WebDriver still running
I/launcher - chrome #01 passed
Process exited with code 0

我的protractor.conf.js

require('ts-node').register({
  compilerOptions: {
    noEmitHelpers: false
  }
});
var helpers = require('./helpers');
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;

exports.config = {
  baseUrl: 'http://localhost:8080/ng2/',

  // use `npm run e2e`
  specs: [
    helpers.root('e2e/**/*.e2e.ts')
  ],
  exclude: [],

  framework: 'jasmine2',

  allScriptsTimeout: 110000,

  jasmineNodeOpts: {
    defaultTimeoutInterval: 600000,
    print: function() {}
  },
  directConnect: true,

  capabilities: {
    'browserName': 'chrome',
    chromeOptions: {
      args: [
        '--start-maximized'
      ]
    }
  },

  onPrepare: function() {
    browser.ignoreSynchronization = true;
    jasmine.getEnv().clearReporters();
    jasmine.getEnv().addReporter(new SpecReporter({  
      displayStacktrace: 'all',
      suite: {
        displayNumber: true,
      },
      spec: {
        displayPending: true,
        displayStacktrace: true,
      },
      summary: {
        displayDuration: true,
      },
      prefixes: {
        successful: '+ ',
        failed: 'x ',
        },
    }));
  },

   useAllAngular2AppRoots: true
};

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。 我的问题是我杀了所有其他记者。 要修复它,删除此行就足够了

jasmine.getEnv().clearReporters();