Angular e2e测试:失败:未定义事件

时间:2019-06-21 06:42:33

标签: angular typescript protractor angular-e2e

该事件在app.e2e-spec.ts中使用时未定义!

  1. 创建一个新项目!

    ng new foo-project
    
  2. 使用VSCode和ng serve打开它。有效!

  3. ng e2e有效!

  4. 在app.e2e-spec.ts中添加一行代码:

    const e = new Event('custom-name');
    

    并再次运行e2e测试。它显示错误:

    **************************************************
    *                    Failures                    *
    **************************************************
    
    1) workspace-project App should display welcome message
      - Failed: Event is not defined
    
    Executed 1 of 1 spec (1 FAILED) in 0.042 sec.
    [14:21:26] I/launcher - 0 instance(s) of WebDriver still running
    [14:21:26] I/launcher - chrome #01 failed 1 test(s)
    [14:21:26] I/launcher - overall: 1 failed spec(s)
    [14:21:26] E/launcher - Process exited with error code 1
    An unexpected error occurred: undefined
    
$ ng version
$ 
Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.9
@angular-devkit/build-angular     0.13.9
@angular-devkit/build-optimizer   0.13.9
@angular-devkit/build-webpack     0.13.9
@angular-devkit/core              7.3.9
@angular-devkit/schematics        7.3.9
@angular/cli                      7.3.9
@ngtools/webpack                  7.3.9
@schematics/angular               7.3.9
@schematics/update                0.13.9
rxjs                              6.3.3
typescript                        3.2.4
webpack                           4.29.0

我很困惑,为什么在写Event文件时没有定义app.e2e-spec.ts,而可以在普通打字稿中使用它。

0 个答案:

没有答案