nice-manchester-42957
07/18/2022, 8:18 PMable-monkey-72947
07/18/2022, 8:20 PMcy.intercept(cyInterceptArgs, request => {
request.on('before:response', response => {
// using env is super odd, but this is how to mix sync / async cy.task / cy.command code
// https://filiphric.com/working-with-api-response-data-in-cypress
Cypress.env('response', response)
})
request.continue()
}).as(url)
Then further down after some fsReadFile
logic,
const response = Cypress.env('response') || null
if (file.shouldRecord && response) {
cy.writeFile(filePath, response)
}
You can save the request/event data into the Cypress.env('response')
, then access it later.able-monkey-72947
07/18/2022, 8:22 PMrequest.on('before:response', response => {...})
nice-manchester-42957
07/18/2022, 8:24 PMable-monkey-72947
07/18/2022, 8:24 PMboundless-optician-46591
07/19/2022, 2:17 AMbrainy-account-24503
07/19/2022, 6:27 AMCypress.Commands.add('myCommand', () => {console.log("fired"})
support/index.js: (According to documentation this should not be necessary)
import './commands.js';
If I do the above the command is not recognized.
If I add the import to support/e2e.js then it's recognized but is not firing.
Anything I'm missing?mammoth-electrician-64243
07/19/2022, 8:17 AMcypress run --browser
. In my setupNodeEvents
I define launch arguments. I see these in the console via a console.log
. However when chrome is opened by browser it seems this is ignored. I can see this by the result shown for the page. If I open the page normaly in chrome launched via the command bellow I get a message I made for you're on mobile. Chrome via command line C:\Program Files\Google\Chrome\Application\chrome.exe" --use-mobile-user-agent --user-agent="Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3559.0 Mobile Safari/537.36"
. Code for `before:browser:launch`:```if (oConfig.oStartup.strBrowser === 'chrome') {
if (oConfig.oStartup.bTestMobile) {
launchOptions.args.push('--use-mobile-user-agent --user-agent="' + oConfig.oStartup.strMobileAgent + '"');
}
else if (oConfig.oStartup.bTestTablet) {
launchOptions.args.push('--use-mobile-user-agent --user-agent="' + oConfig.oStartup.strTabletAgent + '"');
}
return launchOptions
}```
Console log shows it is added to the arguments '--use-mobile-user-agent --user-agent="Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3559.0 Mobile Safari/537.36"'
.
EDIT:
Got it working, you must do one argument per line, so do 2 args.push
in this casefew-telephone-44543
07/19/2022, 8:32 AMwooden-teacher-96595
07/19/2022, 10:23 AMadventurous-afternoon-66082
07/19/2022, 11:09 AMadventurous-afternoon-66082
07/19/2022, 11:10 AMadventurous-afternoon-66082
07/19/2022, 11:10 AMadventurous-afternoon-66082
07/19/2022, 11:11 AMadventurous-afternoon-66082
07/19/2022, 11:12 AMadventurous-afternoon-66082
07/19/2022, 11:12 AMcareful-computer-31749
07/19/2022, 12:01 PMwhite-gpu-56286
07/19/2022, 12:10 PMbrainy-account-24503
07/19/2022, 12:22 PMquiet-orange-53857
07/19/2022, 1:47 PMgray-kilobyte-89541
07/19/2022, 1:53 PMquiet-orange-53857
07/19/2022, 2:05 PMbrash-ghost-16880
07/19/2022, 2:15 PMadorable-stone-42197
07/19/2022, 4:39 PMboundless-optician-46591
07/20/2022, 3:26 AMfew-telephone-44543
07/20/2022, 6:39 AMglamorous-forest-41164
07/20/2022, 10:09 AMglamorous-forest-41164
07/20/2022, 10:15 AMglamorous-forest-41164
07/20/2022, 10:16 AM/Users/nazar/Library/Application Support/Cypress/cy/production/projects/cypress-mocha-bls-test-fd979bc015b928f839f67a025adcb272/bundles/test/unit
Anyone have any idea, is it some configuration related issue or some a bug?handsome-dress-30825
07/20/2022, 11:59 AM