Hi all I have a question. I think i do it wrong and need some help
I have an Json File
{
"navigator":"enkelrader",
"product":"product",
"environment":"test3"
}
And want to get the "navigor" value for later use
and the code is like this
fileToRead(file,dataObj){
let foo;
// cy.readFile(file).its(dataPath).then((obj) => {
cy.readFile(file).then((obj) => {
foo = obj[dataObj]
cy.log(foo)
});
cy.log(foo)
};
And the log from the running
"
readFilecypress/fixtures/variables.json
log enkelrader
log
"
outside the log is empty I support it is because of async behavior. But is possible to assign an variable from readFile() and how to do it?