Is it possible to to feed data into a Testcafe Studio tests so the same test can be completed with different sets of data without having to record a new test each time?
Thanks.
Is it possible to to feed data into a Testcafe Studio tests so the same test can be completed with different sets of data without having to record a new test each time?
Thanks.
Yes, it is possible.
[1, 2, 3].forEach(data => {
test.only
('Data Driven Example', async t => {
console.log(data);
});
});
It will become useful when you have data in some separate file like so:
const testData = require(`../Resources/${process.env.TESTCAFE_ENV}/logIn.json`);
testData.credentials.forEach(credentials => {
test
('Log Into User Account', async t => {
await LogIn.logIn(credentials.username, credentials.password);
await t
.expect(PageMsg.pageMsg.innerText).eql(PageMsg.successfulLogIn)
.expect(Selector(ProfileForm.inputObj.name.input).value).eql(credentials.name);
});
});
All this is mentioned in the official documentation.
EDIT: This is a valid way, but the question is more focused on TestCafe Studio and how to do it in it. Havind said that, my answer doesn't really answer that.