Skip to content

Commit

Permalink
feat(actions): add "When I set Cypress config"
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jan 5, 2024
1 parent adb4ebe commit 7c44fbc
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/actions/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { When } from '@badeball/cypress-cucumber-preprocessor';
import { DataTable, When } from '@badeball/cypress-cucumber-preprocessor';

import { getOptions } from '../utils';

/**
* When I set Cypress config:
Expand All @@ -15,6 +17,13 @@ import { When } from '@badeball/cypress-cucumber-preprocessor';
* When I set Cypress config "defaultCommandTimeout" to "10000"
* ```
*
* Set multiple configuration options:
*
* ```gherkin
* When I set Cypress config
* | defaultCommandTimeout | 10000 |
* ```
*
* @remarks
*
* Configuration set using [`Cypress.config`](https://docs.cypress.io/api/cypress-api/config) _is only in scope for the current spec file_.
Expand All @@ -31,6 +40,12 @@ export function When_I_set_Cypress_config(
name: keyof Cypress.TestConfigOverrides,
value: string,
) {
if ((name as unknown) instanceof DataTable) {
const options = getOptions(name as unknown as DataTable);
Cypress.config(options as Cypress.TestConfigOverrides);
return;
}

switch (value) {
case 'true':
Cypress.config(name, true);
Expand All @@ -54,4 +69,5 @@ export function When_I_set_Cypress_config(
}
}

When('I set Cypress config', When_I_set_Cypress_config);
When('I set Cypress config {string} to {string}', When_I_set_Cypress_config);

0 comments on commit 7c44fbc

Please sign in to comment.