adorable-smartphone-87280
02/15/2023, 3:43 PMroles.map( role => function(role) )
. In my command, there is a Cypress.log()
block at the top, and it immediately prints this out for all four roles before it moves on to the actual test logic. I'm assuming this has something to do with hoisting and/or the async nature of Cypress. Is this something that could be resolved if I defined that function as a Cypress Custom Command, instead of just as a simple function defined as a const
?adorable-smartphone-87280
02/15/2023, 3:49 PM/support/
, but I'm asking about when I want to drop one into a test file directly. How can I declare its types?gray-kilobyte-89541
02/15/2023, 4:24 PMadorable-smartphone-87280
02/15/2023, 10:43 PMmap
gray-kilobyte-89541
02/16/2023, 4:07 PMadorable-smartphone-87280
02/16/2023, 6:48 PMadorable-smartphone-87280
02/16/2023, 6:48 PMit("C69484 Verify Settings Defaults: All Roles", () => {
Object.keys(roles).map((role) => {
verifySettings(role);
});
});
adorable-smartphone-87280
02/16/2023, 6:48 PMverifySettings
custom command:adorable-smartphone-87280
02/16/2023, 6:50 PMconst verifySettings = (role) => {
Cypress.log({
name: "verifySettings",
displayName: "Verify Default Settings for the role:",
message: `${role}`,
});
// Do stuff
};
adorable-smartphone-87280
02/16/2023, 6:51 PM// Do stuff
chunk.adorable-smartphone-87280
02/16/2023, 6:54 PM.map()
is basically expanding the logic of the custom command out into a giant virtual text file and then because of Javascript Hoisting, the Cypress.log()
sections are being boosted to the top and run immediately. I'm looking to confirm if my reasoning is correct on this, and if there's anything that can be done to have the Cypress.log
sections print just before the logic the follows them.gray-kilobyte-89541
02/16/2023, 8:26 PM// Do stuff
means there. I would create a tiny public repo with the spec so other people can run and see it and explain it. This is also helpful in this case https://glebbahmutov.com/blog/visualize-cypress-command-queue