angular - 使用 angular-cli 运行 Protractor 时,SpecReporter 不是构造函数错误

标签 angular protractor angular-cli

当我尝试运行 ng e2e 或直接 protractor 命令时,出现此错误:

[14:39:00] I/update - chromedriver: chromedriver_2.28 up to date
[14:39:04] I/launcher - Running 1 instances of WebDriver
[14:39:04] I/direct - Using ChromeDriver directly...
[14:39:44] E/launcher - Error: TypeError: SpecReporter is not a constructor
    at onPrepare (/home/younes/repo/cip_front/protractor.conf.js:30:34)
    at q_1.Promise (/home/younes/repo/cip_front/node_modules/protractor/lib/util.ts:48:39)
    at Function.promise (/home/younes/repo/cip_front/node_modules/q/q.js:682:9)
    at Object.runFilenameOrFn_ (/home/younes/repo/cip_front/node_modules/protractor/lib/util.ts:39:10)
    at plugins_.onPrepare.then (/home/younes/repo/cip_front/node_modules/protractor/lib/runner.ts:103:21)
    at _fulfilled (/home/younes/repo/cip_front/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (/home/younes/repo/cip_front/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (/home/younes/repo/cip_front/node_modules/q/q.js:796:13)
    at /home/younes/repo/cip_front/node_modules/q/q.js:556:49
    at runSingle (/home/younes/repo/cip_front/node_modules/q/q.js:137:13)
    at flush (/home/younes/repo/cip_front/node_modules/q/q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
[14:39:44] E/launcher - Process exited with error code 100

最佳答案

这是因为 Jasmine 中的重大更改。将 Protractor 配置文件更改为:

var SpecReporter = require('jasmine-spec-reporter').SpecReporter;

代替:

var SpecReporter = require('jasmine-spec-reporter');

关于angular - 使用 angular-cli 运行 Protractor 时,SpecReporter 不是构造函数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43001079/

相关文章:

angular - 安装旧的 Angular 版本 5?

angular - ng 构建抛出错误 : "Tried to find bootstrap code, but could not."

Angular2 HTTP put 添加授权 header

javascript - Protractor + Jasmine : Run same test in parallel with different data inputs

testing - 使用带有元素 by.id Protractor 测试错误的输入框

Angular 2 - ng 构建与 webpack 构建

angular - Angular 真实后端测试服务

javascript - Angular 模块没有导出成员 'fromEvent'

Angular 2 : Circular Feature module dependency

css - 如果 'user' 已登录,我想每次都调用自动检查。如果不是 'user' 登录,然后重定向回(url)