在 Testcafe 中,我可以使用以下内容在 javascript 中定义用户角色:
import { Role,t } from 'testcafe';
export const UserRole:Role=Role('https://example.com/', async (t) => {
await t
.typeText('#LoginID', 'user')
.typeText('#Password', 'Pass1!')
.click('.btn btn-login');
},{preserveUrl:true});
我有一个将 allowJs 设置为 false 的 Typescript 项目,当我在 typescript 代码中使用上述代码时
fixture ('Check logged user')
.beforeEach(async t => {
await t.useRole(UserRole);
});
我明白了
fixture.beforeEach 钩子中的错误 - “角色”参数应该是角色实例,但它是一个对象。