=== @ensono-stacks/playwright:visual-regression-deployment

.Configure visual regression testing within your deployment pipeline
[%collapsible]
=====
[.details]
====
The _visual-regression-deployment_ generator configures your pipeline to enable visual regression testing either natively or through a cloud-based provider.
====

[discrete]
== Usage

----
nx g @ensono-stacks/playwright:visual-regression-deployment
----

Upon calling the _visual-regression-deployment_ generator, you will be presented with a number of options:

- What type of visual regression tests would you like to use?
    - native
    - applitools

You should select the type of visual regression tests that you created through the link:../playwright/plugin-information.adoc[@ensono-stacks/playwright:visual-regression] generator.

[discrete]
== Command line arguments

[cols="1,1,1,1,1]
|===
| Option | Description | Type | Accepted Values | Default

| --type, -t 
| Method used to conduct visual testing 
| string 
| [choices: "native", "applitools"] 
| none
|===

[discrete]
== Generator Output

[discrete]
=== Playwright with native visual comparisons

Opting to scaffold **native** visual testing will make a number of amendments to your test project's configuration:

[source,text]
----
.
├── build
│   ├── azDevOps
│   │   ├── azuredevops-updatesnapshots.yaml #Pipeline to capture and update baseline images within the CI
----

.build/taskctl/tasks.yaml
[source,yaml]
-----
# New update snapshots task definition to update snapshots for all affected projects
e2e:updatesnapshots:
    description: Run e2e snapshot updates in ci
    command:
      - npx nx affected --base="$BASE_SHA" --target=e2e --parallel=1
        --skip-nx-cache --update-snapshots --grep @visual-regression
-----

.taskctl.yaml
----
# Update snapshots task added to taskctl.yaml which can be called by adding a comment to pull requests
updatesnapshots:
    - task: e2e:updatesnapshots
----

NOTE: Visit the link:../../testing/testing_in_nx/playwright_visual_testing.adoc[Updating your baseline images] documentation for further details!

[discrete]
=== Playwright with Applitools Eyes

Opting to scaffold visual testing with **applitools** will make a small change to your test project's configuration:

.build/azDevOps/azuredevops-stages.yaml
[source,yaml]
----
- task: AzureCLI@2
    displayName: build_deployment_${{ parameters.environment }}
        env:
            GH_TOKEN: $(GH_TOKEN)
            APPLITOOLS_API_KEY: $(APPLITOOLS_API_KEY) # API key for Applitools API added
----

NOTE: Visit the link:../../testing/testing_in_nx/playwright_visual_testing_applitools.adoc[Playwright with Applitools Eyes] documentation for further details!
=====
