|
5 | 5 | DEFAULT_BASE_PATH, |
6 | 6 | DEFAULT_TEST_FOLDER_PATH, |
7 | 7 | FIREBASE_TOOLS_YES_ARGUMENT, |
8 | | - FALLBACK_TEST_FOLDER_PATH |
| 8 | + FALLBACK_TEST_FOLDER_PATH, |
| 9 | + SECOND_FALLBACK_TEST_FOLDER_PATH |
9 | 10 | } from './constants'; |
10 | 11 |
|
11 | 12 | /** |
@@ -74,27 +75,45 @@ export function envVarBasedOnCIEnv(varNameRoot) { |
74 | 75 | const prefix = getEnvPrefix(); |
75 | 76 | const combined = `${prefix}${varNameRoot}`; |
76 | 77 |
|
77 | | - // Config file used for environment (local, containers) |
| 78 | + // Config file used for environment (local, containers) from main test path (cypress/config.json) |
78 | 79 | const localTestConfigPath = path.join( |
79 | | - process.cwd(), |
| 80 | + DEFAULT_BASE_PATH, |
80 | 81 | DEFAULT_TEST_FOLDER_PATH, |
81 | 82 | 'config.json' |
82 | 83 | ); |
| 84 | + |
| 85 | + // Load test config from main test path (cypress/config.json) |
83 | 86 | if (fs.existsSync(localTestConfigPath)) { |
84 | 87 | const configObj = require(localTestConfigPath); // eslint-disable-line global-require, import/no-dynamic-require |
85 | 88 | return configObj[combined] || configObj[varNameRoot]; |
86 | 89 | } |
| 90 | + |
| 91 | + // Fallback Attempt for Config file (test/ui) |
87 | 92 | const fallbackConfigPath = path.join( |
88 | | - process.cwd(), |
| 93 | + DEFAULT_BASE_PATH, |
89 | 94 | FALLBACK_TEST_FOLDER_PATH, |
90 | 95 | 'config.json' |
91 | 96 | ); |
92 | 97 |
|
| 98 | + // Load config from the fallback path if it exists (test/ui) |
93 | 99 | if (fs.existsSync(fallbackConfigPath)) { |
94 | 100 | const configObj = require(fallbackConfigPath); // eslint-disable-line global-require, import/no-dynamic-require |
95 | 101 | return configObj[combined] || configObj[varNameRoot]; |
96 | 102 | } |
97 | 103 |
|
| 104 | + // Second Fallback Attempt for Config file (test/e2e) |
| 105 | + const fallback2ConfigPath = path.join( |
| 106 | + DEFAULT_BASE_PATH, |
| 107 | + SECOND_FALLBACK_TEST_FOLDER_PATH, |
| 108 | + 'config.json' |
| 109 | + ); |
| 110 | + |
| 111 | + // Load config from the fallback path if it exists (test/e2e) |
| 112 | + if (fs.existsSync(fallback2ConfigPath)) { |
| 113 | + const configObj = require(fallback2ConfigPath); // eslint-disable-line global-require, import/no-dynamic-require |
| 114 | + return configObj[combined] || configObj[varNameRoot]; |
| 115 | + } |
| 116 | + |
98 | 117 | // CI Environment (environment variables loaded directly) |
99 | 118 | return process.env[combined] || process.env[varNameRoot]; |
100 | 119 | } |
@@ -217,7 +236,9 @@ export function addDefaultArgs(Cypress, args, opts = {}) { |
217 | 236 | // TODO: Load this in a way that understands environment. Currently this will |
218 | 237 | // go to the first project id that is defined, not which one should be used |
219 | 238 | // for the specified environment |
220 | | - const projectId = Cypress.env('firebaseProjectId') || Cypress.env('FIREBASE_PROJECT_ID') || Cypress.env('STAGE_FIREBASE_PROJECT_ID'); |
| 239 | + const projectId = Cypress.env('firebaseProjectId') |
| 240 | + || Cypress.env('FIREBASE_PROJECT_ID') |
| 241 | + || Cypress.env('STAGE_FIREBASE_PROJECT_ID'); |
221 | 242 | // Include project id command so command runs on the current project |
222 | 243 | if (!newArgs.includes('-P') || !newArgs.includes(projectId)) { |
223 | 244 | newArgs.push('-P'); |
|
0 commit comments