我正在使用TestCafe并尝试将Percy集成到视觉回归测试中.我已经导入了Percy SDK,但是我收到了这个错误ReferenceError: XMLHttpRequest is not defined.任何有关如何实现这一点的见解都会有所帮助.
const PercyAgent = require('@percy/agent').default;
export default class Helper {
takeSnapshot(snapshotName: any, snapshotOptions: any) {
const percyAgentClient = new PercyAgent({
clientInfo: 'awesome-percy-sdk@0.0.1',
environmentInfo: 'some helpful os or browser information for debugging',
});
percyAgentClient.snapshot(snapshotName, snapshotOptions);
}
}
Run Code Online (Sandbox Code Playgroud)
test('Regression | Login with wrong credentials | 102', async (t) => {
loginPage.login('not_existent@xpta.com', 'RandomPassword1');
await t.expect(loginPage.errorMessage.visible).ok();
await t.debug();
await t.expect(loginPage.errorMessage.innerText).eql('Invalid username or password.');
await helper.takeSnapshot('wrong credentials', {});
});
Run Code Online (Sandbox Code Playgroud) 我有一个使用元标记的测试套件,我正在尝试运行特定的测试。
我尝试使用以下方法:
.filter((fixturePath, fixtureName, testMeta) => {
return testMeta.smoke == 'true';
})
Run Code Online (Sandbox Code Playgroud)
跑步者.ts
const createTestCafe = require('testcafe');
let testcafe = null;
createTestCafe('localhost', 1337, 1338)
.then((tc) => {
testcafe = tc;
const runner = testcafe.createRunner();
return runner
.src(['tests/specs/**/*.spec.ts'])
.filter((fixturePath, fixtureName, testMeta) => {
return testMeta.smoke == 'true';
})
.browsers(['chrome'])
.reporter([
'list'
])
.run();
})
.then((failedCount) => {
console.log('Tests failed: ' + failedCount);
testcafe.close();
});
示例测试
test('Login with correct credentials', async (t) => {
await LoginPage.login(data.users.userPrivate.username, data.users.userPrivate.password);
await t.expect(Helper.getLocation()).contains(endpoints.personalAreaOverview);
}).meta('regression', 'true').meta('smoke', 'true'); …