Skip to content

Commit

Permalink
feat: Sync attachments to assets directory (#285)
Browse files Browse the repository at this point in the history
* feat: Sync attachments to assets directory

* set web assets env var

* plugin only picks the env var without prefix

* debug

* env is set under suite.config

* env is set under suite.config

* fix bug

* bump package

* remove debug
  • Loading branch information
tianfeng92 authored Apr 10, 2024
1 parent 2fc8304 commit b9f4a7b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
26 changes: 16 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@cypress/webpack-preprocessor": "6.0.1",
"@cypress/xpath": "2.0.3",
"@saucelabs/cypress-junit-plugin": "0.2.0",
"@saucelabs/cypress-plugin": "3.1.3",
"@saucelabs/cypress-plugin": "3.2.1",
"@shelex/cypress-allure-plugin": "2.40.1",
"@tsconfig/node20": "20.1.2",
"babel-loader": "9.1.3",
Expand Down
12 changes: 10 additions & 2 deletions src/cypress-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ function setEnvironmentVariables(runCfg: RunConfig, suiteName: string) {

process.env.CYPRESS_SAUCE_SUITE_NAME = suite.name;
process.env.CYPRESS_SAUCE_ARTIFACTS_DIRECTORY = runCfg.resultsDir;
process.env.SAUCE_WEB_ASSETS_DIR =
suite.config?.env?.SAUCE_SYNC_WEB_ASSETS?.toLowerCase() === 'true'
? runCfg.resultsDir
: '';

for (const [key, value] of Object.entries(envVars)) {
process.env[key] = value as string;
Expand Down Expand Up @@ -148,6 +152,10 @@ function getCypressOpts(
}

const testingType = suite.config.testingType || 'e2e';
const cypressOutputDir =
suite.config?.env?.SAUCE_SYNC_WEB_ASSETS?.toLowerCase() === 'true'
? undefined
: runCfg.resultsDir;

let opts: Partial<CypressCommandLine.CypressRunOptions> = {
project: path.dirname(cypressCfgFile),
Expand All @@ -161,8 +169,8 @@ function getCypressOpts(
specPattern: suite.config.specPattern,
excludeSpecPattern: suite.config.excludeSpecPattern || [],
},
videosFolder: runCfg.resultsDir,
screenshotsFolder: runCfg.resultsDir,
videosFolder: cypressOutputDir,
screenshotsFolder: cypressOutputDir,
video: shouldRecordVideo(),
videoCompression: false,
env: getEnv(suite),
Expand Down

0 comments on commit b9f4a7b

Please sign in to comment.