Skip to content

Commit

Permalink
feat(nx): add in env option for Cypress Builder
Browse files Browse the repository at this point in the history
Add in env property to cypress builder that can be set from the angular.json in the options section
  • Loading branch information
nfavero authored and vsavkin committed May 14, 2019
1 parent 84deb16 commit 9618413
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/cypress/src/builders/cypress/cypress.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface CypressBuilderOptions extends JsonObject {
tsConfig: string;
watch: boolean;
browser?: string;
env?: Record<string, string>;
}

try {
Expand Down Expand Up @@ -78,7 +79,8 @@ function run(
options.parallel,
options.watch,
baseUrl,
options.browser
options.browser,
options.env
)
),
options.watch ? tap(noop) : take(1),
Expand Down Expand Up @@ -184,7 +186,8 @@ function initCypress(
parallel: boolean,
isWatching: boolean,
baseUrl: string,
browser?: string
browser?: string,
env?: Record<string, string>
): Observable<BuilderOutput> {
// Cypress expects the folder where a `cypress.json` is present
const projectFolderPath = path.dirname(cypressConfig);
Expand All @@ -201,6 +204,10 @@ function initCypress(
options.browser = browser;
}

if (env) {
options.env = env;
}

options.exit = exit;
options.headed = !headless;
options.record = record;
Expand Down
4 changes: 4 additions & 0 deletions packages/cypress/src/builders/cypress/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
"type": "string",
"description": "The browser to run tests in.",
"enum": ["electron", "chrome", "chromium", "canary"]
},
"env": {
"type": "object",
"description": "A key-value Pair of environment variables to pass to Cypress runner"
}
},
"additionalProperties": false,
Expand Down

0 comments on commit 9618413

Please sign in to comment.