You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey :) So I noticed that there are little examples in the documentation regarding before:spec, before:run, after:spec, after:run. I've been looking for a few hours for a way to dump the data generated in before:spec into the spec file (which matches the if).
Does anyone have an idea how to do this (or has documented example)? It generally works for me if I throw in the main exported function, but that doesn't quite do what I want because it only gets called before all the spec files.
This is what I have for now, which is working but it's not 100% what I want:
// plugins/index.jsmodule.exports=(onconfig)=>{// magicconstmyVariable="Magical value";config.env.magical=myVariable;returnconfig;}// test.spec.jsconstniceVariable=Cypress.env("magical")// get "Magical value"
What I need (pseudo code/not working)
module.exports=(onconfig)=>{on("before:spec",async({ relative })=>{if(relative==="cypress/integration/test.spec.js"){// magicconstmyVariable="Magical value";config.env.magical=myVariable;}});returnconfig;}// test.spec.jsconstniceVariable=Cypress.env("magical")// get "Magical value" (for now getting undefined)
Edit
Ok, sounds like I can't change envs... at all, so working with task in before?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey :) So I noticed that there are little examples in the documentation regarding
before:spec
,before:run
,after:spec
,after:run
. I've been looking for a few hours for a way to dump the data generated inbefore:spec
into the spec file (which matches the if).Does anyone have an idea how to do this (or has documented example)? It generally works for me if I throw in the main exported function, but that doesn't quite do what I want because it only gets called before all the spec files.
This is what I have for now, which is working but it's not 100% what I want:
What I need (pseudo code/not working)
Edit
Ok, sounds like I can't change envs... at all, so working with task in before?
Beta Was this translation helpful? Give feedback.
All reactions