Replies: 2 comments
-
Please read the blog post https://glebbahmutov.com/blog/why-cy-log-prints-nothing/ |
Beta Was this translation helpful? Give feedback.
0 replies
-
ok. Thank you. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
HI Team,
I can get the value from some other server in plugins file using cy.task() command. But not able to use the returned value(resolved using then) outside the task command block. I need to assign the returned(resolved value) into variable and need to use those values or pass the value into other functions.
How can I achieve this. Tried lot.
Also can I use one more file with methods and import the new file functions into index.js(plugins folder) and access the methods using task command is possible?
TestCase:
describe('T700_L600CD_L600CD_T700', ()=>{
before('before', ()=>{
cy.log('before block');
});
it.only('get-val-using-task', ()=>{
let data;
cy.task('getIPDetail').then(res=>{
data = res;
cy.log(data);//printing value
});
cy.log(data); //empty
});
});
plugins-index file:
const getIPDetails = ()=>{
return new Promise((res, rej)=>{
res({"ip":"1.1.1.1", "username":"sen"});
});
};
module.exports = (on, config) => {
//
on
is used to hook into various events Cypress emits//
config
is the resolved Cypress configon('task', {
getIPDetail(){
return getIPDetails();
}
});
};
Kindly help me on this.
Thanks
Senthilkumar TR
Beta Was this translation helpful? Give feedback.
All reactions