ctw*_*twx 6 cache-control angular cypress
我目前正在使用 Cypress 6.4.0,它启动我的 Angular 应用程序。这个Angular应用程序在开始时调用后端的时间同步路由。我们通过以下方式拦截此调用:
cy.wait('/api/t', { requestTimeout: 10_000 }).then((req) => {
expect(req.response!.statusCode).to.equal(200);
// some extra stuff...
});
Run Code Online (Sandbox Code Playgroud)
这对于第一次测试有效,但第二次测试总是失败。我检查了网络日志,似乎第二个响应来自浏览器缓存。我首先认为后端或 Angular 的缓存删除了pragma和no-cache标头,但是当在没有 Cypress 的情况下运行应用程序时,标头就在那里。
我的测试中有两个测试,第二个测试失败了。或者,如果我有 1 个测试,并使用R.
那么,有没有办法禁用 Cypress 中的缓存呢?
查看Gleb Bahmutov 博客上有关拦截问题的帖子
cy.intercept('/todos', req => {
delete req.headers['if-none-match']
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2066 次 |
| 最近记录: |