Skip to content

How to get the variable set inside module.exports #14433

Discussion options

You must be logged in to vote

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"
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bahmutov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants