在角度e2e测试中绕过身份验证保护

时间:2020-11-05 15:06:09

标签: angular e2e-testing

我正在尝试在我的应用程序中测试页面,但是通常该页面需要登录用户才能访问它。我想绕过此身份验证防护,因此无需登录即可访问页面,因为此测试并非旨在测试防护功能。

// clients.routing.module.ts
const clientsRoutes: Routes = [
  {
    path: 'clients',
    component: ClientIndexPage,
    canActivate: [AuthGuard],
    data: {animation: 'ClientIndexPage'}
  },
  ...
]

// client-index.e2e-spec.ts
describe('ClientIndex', () => {

  beforeEach(() => {
    browser.get('/clients');
  })

  it("should set the page title correctly", () => {
    expect(browser.getTitle()).toEqual("Client Index")
  })
})

这是我嘲笑AuthGuard的情况吗?我该怎么办?

0 个答案:

没有答案