Jos*_*man 5 firebase reactjs firebase-authentication cypress
当我需要在经过身份验证的页面上测试某些内容时,我在钩子之前使用以下内容:
beforeEach('login', () => {
cy.visit('/protected', {
onBeforeLoad: (win) => {
win.localStorage.setItem(user1.key, user1.token);
},
});
cy.on('uncaught:exception', (err, runnable) => {
console.error(err);
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
user.1 是从“../fixtures/testUsers”导入的,我将键值对复制并粘贴到浏览器存储中。
要获取键值对,我使用社交帐户登录,然后Application在开发工具中打开选项卡,Local Storage在左侧面板中打开,然后复制包含字符串的键和值firebase:authUser...。
有用。
更重要的是,它让我可以使用两个不同的帐户登录,获取两组不同的用户密钥,然后在我的测试中模拟它们之间的交互。
但至少可以说,这感觉很糟糕。
这种方法有什么问题吗?有没有“适当”的方法来做到这一点?
| 归档时间: |
|
| 查看次数: |
778 次 |
| 最近记录: |