feat(nx): add in spec option for Cypress Builder

Add in spec option to angular.json so it can be passed to they cypress builder
This commit is contained in:
Nick Favero 2019-05-22 15:41:36 -06:00 committed by Victor Savkin
parent 356d288fd6
commit cf5ebf59d7
2 changed files with 12 additions and 2 deletions

View File

@ -29,6 +29,7 @@ export interface CypressBuilderOptions extends JsonObject {
watch: boolean; watch: boolean;
browser?: string; browser?: string;
env?: Record<string, string>; env?: Record<string, string>;
spec?: string;
} }
try { try {
@ -80,7 +81,8 @@ function run(
options.watch, options.watch,
baseUrl, baseUrl,
options.browser, options.browser,
options.env options.env,
options.spec
) )
), ),
options.watch ? tap(noop) : take(1), options.watch ? tap(noop) : take(1),
@ -187,7 +189,8 @@ function initCypress(
isWatching: boolean, isWatching: boolean,
baseUrl: string, baseUrl: string,
browser?: string, browser?: string,
env?: Record<string, string> env?: Record<string, string>,
spec?: string
): Observable<BuilderOutput> { ): Observable<BuilderOutput> {
// Cypress expects the folder where a `cypress.json` is present // Cypress expects the folder where a `cypress.json` is present
const projectFolderPath = path.dirname(cypressConfig); const projectFolderPath = path.dirname(cypressConfig);
@ -207,6 +210,9 @@ function initCypress(
if (env) { if (env) {
options.env = env; options.env = env;
} }
if (spec) {
options.spec = spec;
}
options.exit = exit; options.exit = exit;
options.headed = !headless; options.headed = !headless;

View File

@ -56,6 +56,10 @@
"env": { "env": {
"type": "object", "type": "object",
"description": "A key-value Pair of environment variables to pass to Cypress runner" "description": "A key-value Pair of environment variables to pass to Cypress runner"
},
"spec": {
"type": "string",
"description": "A comma delimited glob string that is provided to the Cypress runner to specify which spec files to run. i.e. '**examples/**,**actions.spec**"
} }
}, },
"additionalProperties": false, "additionalProperties": false,