import { When } from '@badeball/cypress-cucumber-preprocessor';

/**
 * When I screenshot:
 *
 * ```gherkin
 * When I screenshot
 * ```
 *
 * When I screenshot with filename:
 *
 * ```gherkin
 * When I screenshot {string}
 * ```
 *
 * The screenshot will be stored in the [screenshots folder](https://docs.cypress.io/guides/references/configuration#Folders--Files) (e.g., `cypress/screenshots`).
 *
 * @example
 *
 * Take a screenshot with an autogenerated filename:
 *
 * ```gherkin
 * When I screenshot
 * ```
 *
 * Take a screenshot with a specified filename:
 *
 * ```gherkin
 * When I screenshot "path/to/screenshot"
 * ```
 *
 * _When passed a path, the folder structure will be created._
 *
 * @remarks
 *
 * Takes a screenshot of the application under test. See [naming conventions](https://docs.cypress.io/api/commands/screenshot#Naming-conventions).
 */
export function When_I_screenshot(filename: string) {
  cy.screenshot(filename);
}

When('I screenshot', When_I_screenshot);
When('I screenshot {string}', When_I_screenshot);
