csspin_python.playwright

The playwright plugin provides a way to run the pytest-playwright end-to-end testing tool to execute pre-implemented tests against CONTACT Elements instances by adding the playwright task to spin’s CLI.

Important

The csspin_python.playwright plugin has been deprecated and will be removed with csspin_python 4.0.0. Please use the plugin csspin_python.pytest with the pytest.playwright.enabled=True setting instead.

How to setup the playwright plugin?

For using the playwright plugin, a project’s spinfile.yaml must at least contain the following configuration.

Minimal configuration of spinfile.yaml to leverage playwright
plugin_packages:
    - csspin-python
plugins:
    - csspin_python.playwright
python:
    version: "3.11.9"

The provisioning of the required virtual environment as well as the plugins dependencies can be done via the well-known spin provision-task.

The plugin is now ready to use: spin playwright --help.

How to execute the playwright task?

After provision, the playwright task can be executed as follows:

Executing playwright
spin playwright

The playwright task will execute the tests defined in the tests/playwright directory of the project. These path can be customized using the playwright configuration within the spinfile.yaml.

How to run playwright tests against a CONTACT Elements instance?

Running playwright tests against a CONTACT Elements instance requires the existence of it. A typical setup may require a spinfile.yaml as follows:

Configuration of spinfile.yaml to run playwright tests against a CONTACT Elements instance
plugin_packages:
    - csspin-ce
    - csspin-frontend
    - csspin-java
    - csspin-python
plugins:
    - csspin_ce:
        - mkinstance # for creating a CE instance
        - ce_services # for starting/stopping CE services
    - csspin_frontend.node
    - csspin_python.playwright
python:
    version: '3.11.9'
    index_url: <index url where to retrieve cs.* packages from>
node:
    version: '18.17.1'
java:
    version: '21'

After provisioning the project, the CONTACT Elements instance can be created and tested using the mkinstance and playwright tasks:

Provisioning and running playwright tests against a CONTACT Elements instance
spin provision
spin mkinstance
spin playwright

How to debug tests?

Debugging tests executed by the playwright plugin using debugpy can be achieved by passing the --debug option when calling playwright. To diverge from the default configuration used to run debugpy, one can adjust the {debugpy.opts}.

Debugging tests using the playwright plugin
spin playwright --debug

As soon as the debugpy server is listening, one can attach to it using the desired IDE or debugger.

playwright schema reference

playwright: 'object'

The pytest plugin provides the full pytest experience for spin. This plugin is deprecated, use the pytest plugin with the ‘pytest.playwright.enabled=true’ setting instead.

playwright.browsers_path: 'path'

Path for playwright to install the browsers.

playwright.browsers: 'list'

The browsers to install and to use for running the playwright tests.

playwright.coverage: 'bool'

Enable or disable code coverage analysis.

playwright.coverage_opts: 'list'

Additional options for the coverage run.

playwright.coverage_report: 'str'

File to write the coverage report to.

playwright.opts: 'list'

Additional options for the pytest command.

playwright.test_report: 'path'

Path to write the test report to.

playwright.tests: 'list'

List of test files or directories to include.

playwright.schema: 'object'
playwright.requires: 'object'
playwright.requires.spin: 'list'
playwright.requires.python: 'list'
playwright._requires: 'list'