How to get the variable set inside module.exports #14433
Answered
by
bahmutov
karthik22061993
asked this question in
Questions and Help
-
I am using cypress framework to test node app. I want to check variable is set to 'SUCCESS'. Intially it is set to 'FAILURE' but from cypress exec it is set to 'SUCCESS'. But when I invoke the function it is still 'FAILURE'. Can someone help me understand where I made it wrong. I will be using similiar logic to login to portal. Please let me know If more details are needed. I have tried demo my idea via code snippet below.
|
Beta Was this translation helpful? Give feedback.
Answered by
bahmutov
Jan 6, 2021
Replies: 1 comment
-
The commands are asynchronous. If you want to return a value you would do this.SuccessMsg = function() {
return cy.exec('echo hello', { log: true, failOnNonZeroExit: false }).then(() => {
return 'success'
});
}
// from your test
helper.SuccessMsg().then(result => {
console.log(result) // prints "success"
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
bahmutov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The commands are asynchronous. If you want to return a value you would do