crooked-article-24217
09/21/2022, 9:34 AMcold-apartment-77594
09/21/2022, 9:58 AMcypress.env.json
files? For example, cypress.env.development.json
and cypress.env.production.json
? I have four different environments and need to set baseUrl
, video
and some custom variables differently, depending on the environment. I was expecting a CLI option but only found --env
, which is not what I want.stale-optician-85950
09/21/2022, 10:07 AMcypress.config.ts
I have /cypress/configs/cypress.mobile.config.ts
and my mobile config uses defu
node package to safely override specified values:
import { defineConfig } from 'cypress';
import defu from 'defu';
import defaultConfig from '../../cypress.config';
export default defineConfig(
defu(
{
viewportWidth: 375,
viewportHeight: 812,
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) Mobile/15E148',
env: {
device: 'mobile',
},
e2e: {
excludeSpecPattern: ['**/e2e/site-monitoring/*', '**/e2e/keyboard-navigation/*'],
},
},
defaultConfig
)
);
You'd just need to readjust for test environment specific values.
And run command is like: cypress run --browser chrome --config-file cypress/configs/cypress.mobile.config.ts
https://docs.cypress.io/guides/guides/command-line#cypress-run-config-file-lt-configuration-file-gticy-exabyte-68383
09/21/2022, 11:36 AMquiet-gold-71638
09/21/2022, 11:36 AMmysterious-belgium-25713
09/21/2022, 11:51 AMmysterious-belgium-25713
09/21/2022, 12:01 PMcold-apartment-77594
09/21/2022, 1:13 PMred-raincoat-97557
09/21/2022, 1:32 PMclever-park-72905
09/21/2022, 2:09 PMcool-toothbrush-53313
09/21/2022, 3:32 PMcool-toothbrush-53313
09/21/2022, 3:32 PMfreezing-piano-2792
09/21/2022, 5:45 PMlittle-midnight-87756
09/21/2022, 6:07 PMmysterious-belgium-25713
09/21/2022, 6:10 PMlittle-midnight-87756
09/21/2022, 6:10 PMlittle-midnight-87756
09/21/2022, 6:11 PMlittle-midnight-87756
09/21/2022, 6:11 PMmicroscopic-fish-5767
09/21/2022, 8:21 PMsteep-businessperson-83821
09/21/2022, 9:02 PMbored-school-78265
09/21/2022, 9:13 PMDEBUG=cypress:server:browsers*,cypress:launcher:browsers*
and see if you can spot anything out of the ordinary.mysterious-belgium-25713
09/21/2022, 9:28 PMmicroscopic-advantage-2187
09/21/2022, 9:36 PMstale-optician-85950
09/21/2022, 10:24 PMalias
a specific value returned from cy.session()
?
Seen in my code as .as('jwtToken')
, when I do this the whole response is aliased and not just the cookie I need for later usage.
cy.session('session caching', () => {
cy.request({
method: 'POST',
url: `${urlUnderTest.origin}/auth/`,
failOnStatusCode: false,
body: {
password: Cypress.env('AUTH_PASSWORD'),
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
}).then(({ allRequestResponses }) => {
cy.wrap(allRequestResponses[0]['Response Headers']['set-cookie'][0]).as('jwtToken');
});
});
cy.visit(urlUnderTest.toString());
cool-toothbrush-53313
09/21/2022, 10:25 PMbreezy-yak-81068
09/21/2022, 10:30 PMstale-optician-85950
09/21/2022, 10:48 PMalias
acool-toothbrush-53313
09/21/2022, 10:50 PMlittle-midnight-87756
09/21/2022, 11:06 PMlittle-midnight-87756
09/21/2022, 11:23 PM