Skip to content

Commit

Permalink
env var for cypress results dir
Browse files Browse the repository at this point in the history
  • Loading branch information
christianvogt committed Jul 2, 2024
1 parent 18bfe2d commit b1b895b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
12 changes: 6 additions & 6 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
"coverage:merge": "rimraf coverage && istanbul-merge --out coverage/coverage-final.json jest-coverage/coverage-final.json src/__tests__/cypress/coverage/coverage-final.json && nyc report --reporter html -t coverage --report-dir coverage/report && nyc report --reporter json-summary -t coverage --report-dir coverage",
"cypress:open": "cypress open --project src/__tests__/cypress",
"cypress:run": "cypress run -b chrome --project src/__tests__/cypress",
"cypress:open:mock": "MOCK=1 WS_PORT=9002 npm run cypress:open -- ",
"cypress:run:mock": "MOCK=1 WS_PORT=9002 npm run cypress:run -- ",
"cypress:run:mock:coverage": "rimraf src/__tests__/cypress/coverage src/__tests__/cypress/.nyc_output && COVERAGE=true npm run cypress:run:mock",
"cypress:open:record": "RECORD=1 npm run cypress:open",
"cypress:run:record": "RECORD=1 npm run cypress:run && npm run cypress:format",
"cypress:open:mock": "CY_MOCK=1 CY_WS_PORT=9002 npm run cypress:open -- ",
"cypress:run:mock": "CY_MOCK=1 CY_WS_PORT=9002 npm run cypress:run -- ",
"cypress:run:mock:coverage": "rimraf src/__tests__/cypress/coverage src/__tests__/cypress/.nyc_output && CY_COVERAGE=true npm run cypress:run:mock",
"cypress:open:record": "CY_RECORD=1 npm run cypress:open",
"cypress:run:record": "CY_RECORD=1 npm run cypress:run && npm run cypress:format",
"cypress:server:build": "ODH_DIST_DIR=./public-cypress POLL_INTERVAL=9999999 FAST_POLL_INTERVAL=9999999 WS_HOSTNAME=localhost:9002 npm run build",
"cypress:server:build:coverage": "COVERAGE=true npm run cypress:server:build",
"cypress:server:build:coverage": "CY_COVERAGE=true npm run cypress:server:build",
"cypress:server": "serve ./public-cypress -p 9001 -s -L",
"cypress:server:dev": "POLL_INTERVAL=9999999 FAST_POLL_INTERVAL=9999999 ODH_PORT=9001 WS_HOSTNAME=localhost:9002 npm run start:dev",
"cypress:format": "prettier --write src/__tests__/**/*.snap.json"
Expand Down
22 changes: 12 additions & 10 deletions frontend/src/__tests__/cypress/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { interceptSnapshotFile } from '~/__tests__/cypress/cypress/utils/snapsho
import { setup as setupWebsockets } from '~/__tests__/cypress/cypress/support/websockets';

[
`.env.cypress${process.env.MOCK ? '.mock' : ''}.local`,
`.env.cypress${process.env.MOCK ? '.mock' : ''}`,
`.env.cypress${process.env.CY_MOCK ? '.mock' : ''}.local`,
`.env.cypress${process.env.CY_MOCK ? '.mock' : ''}`,
'.env.local',
'.env',
].forEach((file) =>
Expand All @@ -24,7 +24,9 @@ import { setup as setupWebsockets } from '~/__tests__/cypress/cypress/support/we
}),
);

const resultsDir = `results/${process.env.MOCK ? 'mocked' : 'e2e'}`;
const resultsDir = `${process.env.CY_RESULTS_DIR || 'results'}/${
process.env.CY_MOCK ? 'mocked' : 'e2e'
}`;

export default defineConfig({
experimentalMemoryManagement: true,
Expand Down Expand Up @@ -52,13 +54,13 @@ export default defineConfig({
screenshotsFolder: `${resultsDir}/screenshots`,
videosFolder: `${resultsDir}/videos`,
env: {
MOCK: !!process.env.MOCK,
MOCK: !!process.env.CY_MOCK,
LOGIN_USERNAME: process.env.LOGIN_USERNAME,
LOGIN_PASSWORD: process.env.LOGIN_PASSWORD,
LOGIN_PROVIDER: process.env.LOGIN_PROVIDER,
RECORD: !!process.env.RECORD,
WS_PORT: process.env.WS_PORT,
coverage: !!process.env.COVERAGE,
RECORD: !!process.env.CY_RECORD,
WS_PORT: process.env.CY_WS_PORT,
coverage: !!process.env.CY_COVERAGE,
codeCoverage: {
exclude: [path.resolve(__dirname, '../../third_party/**')],
},
Expand All @@ -68,9 +70,9 @@ export default defineConfig({
defaultCommandTimeout: 10000,
e2e: {
baseUrl: process.env.BASE_URL,
specPattern: process.env.MOCK
specPattern: process.env.CY_MOCK
? `cypress/tests/mocked/**/*.cy.ts`
: process.env.RECORD
: process.env.CY_RECORD
? `cypress/tests/mocked/**/*.scy.ts`
: `cypress/tests/e2e/**/*.cy.ts`,
experimentalInteractiveRunEvents: true,
Expand Down Expand Up @@ -108,7 +110,7 @@ export default defineConfig({
},
});

if (process.env.RECORD) {
if (process.env.CY_RECORD) {
on('before:spec', (spec) => {
// delete previous snapshots for the spec
try {
Expand Down

0 comments on commit b1b895b

Please sign in to comment.