【发布时间】:2018-06-12 19:16:43
【问题描述】:
在我正在测试的应用程序中,组件类中有显示 toastr 消息的行。我正在尝试编写一个量角器测试来测试这些消息是否显示但很难。原因是我的 HTML 中没有提到 toastr,所以我真的不知道如何让量角器找到它。这是我使用 toastr 的代码。如果用户注册或更新,我想测试是否显示成功消息。
dialogRef.afterClosed().subscribe(result => {
console.log(result);
if (result.success === "success") {
this.toastr.success(result.isToEdit == true ? "User is updated successfully " : "User is created successfully.");
this.getUsers();
}
});
我对这个摸不着头脑。任何帮助都会很棒。谢谢!
编辑:我相信我已经解决了这个问题。我执行以下代码来访问消息:
return element(by.css('.toast-message'))
【问题讨论】:
-
您使用的是哪个
toastr库? -
在我的模块文件中: import { ToastModule } from 'ng2-toastr/ng2-toastr';
标签: angular jasmine protractor toastr