该事件在app.e2e-spec.ts
中使用时未定义!
创建一个新项目!
ng new foo-project
使用VSCode和ng serve
打开它。有效!
ng e2e
有效!
在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
,而可以在普通打字稿中使用它。