I have a custom command to get user data from SQL Server, which works fine. But now I cannot find a way to loop through the data returned.
I need something like this:
var users = []
describe('start tests ', () => {
before(() => {
cy.getUser(1, 0).then(value => {
users.push(value)
});
})
users.forEach((u) => {
it("Test for user " + u['username'], () => {
// test script here
});
});
})
But it doesn't work because JavaScript forEach part is not waiting for the cy.before(). I tried and searched but cannot find a solution. Any ideas? Thanks.
before:runwill executed at all other tests too. And the detour withwriteJsonwill maybe not work on the destination server because strict seurity settings.before:runis run before the run - I guess it's well named :). So the data is set up, but obviously a test does not have to use it.getUseris a custom command that makes request to the SQL server. This slows down any other test even if they don't use the data. And vith the param in thegetUserfunction I select specific user, other testI select different user.before:runusing an environment variable. Just a suggestion.