From 2f608943b2365b75a8d0693cec2167bd5f9ba546 Mon Sep 17 00:00:00 2001 From: 3v0k4 Date: Fri, 12 Dec 2025 17:31:12 +0100 Subject: [PATCH 1/2] Reapply "docs: playwright" This reverts commit 093600aea6c444593dc44ae1d3989c1aa20eb837. --- docusaurus/docs/index.mdx | 12 +- docusaurus/docs/playwright/cookbook.md | 23 + docusaurus/docs/playwright/guide/index.mdx | 765 ++++++++++++++++++ docusaurus/docs/playwright/reference.md | 174 ++++ docusaurus/docs/playwright/troubleshooting.md | 34 + docusaurus/docs/troubleshooting/index.mdx | 10 +- docusaurus/sidebars.ts | 38 + docusaurus/src/css/custom.css | 2 +- docusaurus/static/img/playwright.svg | 9 + 9 files changed, 1061 insertions(+), 6 deletions(-) create mode 100644 docusaurus/docs/playwright/cookbook.md create mode 100644 docusaurus/docs/playwright/guide/index.mdx create mode 100644 docusaurus/docs/playwright/reference.md create mode 100644 docusaurus/docs/playwright/troubleshooting.md create mode 100644 docusaurus/static/img/playwright.svg diff --git a/docusaurus/docs/index.mdx b/docusaurus/docs/index.mdx index c9e3829f..60604e27 100644 --- a/docusaurus/docs/index.mdx +++ b/docusaurus/docs/index.mdx @@ -3,13 +3,14 @@ pagination_prev: null pagination_next: overview/index --- +import Playwright from "@site/static/img/playwright.svg" +import Vitest from "@site/static/img/vitest.svg" import api from "@site/static/img/api.png"; +import cypress from "@site/static/img/cypress.jpg" import javascript from "@site/static/img/javascript.png" -import Vitest from "@site/static/img/vitest.svg" import jest from "@site/static/img/jest.jpg" -import cypress from "@site/static/img/cypress.jpg" -import ruby from "@site/static/img/ruby.png" import knapsack from "@site/static/img/knapsack.png" +import ruby from "@site/static/img/ruby.png" import troubleshooting from "@site/static/img/troubleshooting.png" # Welcome @@ -49,6 +50,11 @@ If you have questions, feel free to [contact us](https://knapsackpro.com/contact

Vitest

+ + +
+

Playwright

+
Can't see your language/testing framework above? [Let us know](https://docs.google.com/forms/d/e/1FAIpQLSe7Z6k__VczmRMmXykjA5i2MVEA3nEJ90gbiIeCRjecWhPOig/viewform?hl=en). diff --git a/docusaurus/docs/playwright/cookbook.md b/docusaurus/docs/playwright/cookbook.md new file mode 100644 index 00000000..326779f9 --- /dev/null +++ b/docusaurus/docs/playwright/cookbook.md @@ -0,0 +1,23 @@ +--- +pagination_next: null +pagination_prev: null +--- + +# Playwright Cookbook + +## Run a subset of tests + +To run a subset of your test suite you can use the `KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE` environment variable: + +- [`KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE`](reference.md#knapsack_pro_test_file_list_source_file) + +## Test coverage + +Use the [blob reporter](https://playwright.dev/docs/test-reporters#blob-reporter) without specifying an `outputDir` or `outputFile`. Later, execute `playwright --merge-reports` to output coverage or any aggregated reports you need (e.g., `json`): + +```bash +npx @knapsack-pro/playwright --coverage --reporter=blob,@knapsack-pro/playwright/reporters/batch +npx playwright merge-reports --coverage +``` + +Knapsack Pro generates one blob file per batch of tests executed named as follows: `blob-report/TODO` (e.g., `TODO`). diff --git a/docusaurus/docs/playwright/guide/index.mdx b/docusaurus/docs/playwright/guide/index.mdx new file mode 100644 index 00000000..a8f229d7 --- /dev/null +++ b/docusaurus/docs/playwright/guide/index.mdx @@ -0,0 +1,765 @@ +--- +toc_max_heading_level: 2 +pagination_next: null +pagination_prev: null +--- + +import { RadioGroup } from '@site/src/components/RadioGroup' +import { ShowIfSearchParam, ShowIfSearchParamAndValue } from '@site/src/components/ShowIf' +import { DelayHashNavigation } from '@site/src/components/DelayHashNavigation' +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Knapsack Pro Playwright: Quickstart + + + +[Create an account](https://knapsackpro.com?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide) to generate API tokens and use Knapsack Pro. + +## Installation + +Make sure you have `playwright` in your `package.json` because `@knapsack-pro/playwright` uses the version installed in your project. + + + + +```bash +npm install --save-dev @knapsack-pro/playwright +``` + + + + +```bash +yarn add --dev @knapsack-pro/playwright +``` + + + + +Also, you must use the `@knapsack-pro/playwright/reporters/batch` reporter. You can either add it in `playwright.config.ts`: + +```js + reporter: [ + // ... + ['@knapsack-pro/playwright/reporters/batch'] + ], +``` + +or pass it every time you invoke `@knapsack-pro/playwright`: + +```bash +npx @knapsack-pro/playwright --reporter=...,@knapsack-pro/playwright/reporters/batch +``` + +Now, fill in the following form to generate the instruction steps for your project: + +**What is your CI provider?** + + +## Instructions + + + +### AppVeyor + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_appveyor) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +For each parallel job, define: + +- [`KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT`](../reference.md#knapsack_pro_test_suite_token_playwright) +- [`KNAPSACK_PRO_CI_NODE_TOTAL`](../reference.md#knapsack_pro_ci_node_total) +- [`KNAPSACK_PRO_CI_NODE_INDEX`](../reference.md#knapsack_pro_ci_node_index) + +Remember to configure the number of parallel CI nodes in AppVeyor. + + + + +```bash +KNAPSACK_PRO_CI_NODE_TOTAL=N \ +KNAPSACK_PRO_CI_NODE_INDEX=0 \ +KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ +npx @knapsack-pro/playwright +``` + + + + +```bash +KNAPSACK_PRO_CI_NODE_TOTAL=N \ +KNAPSACK_PRO_CI_NODE_INDEX=1 \ +KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ +npx @knapsack-pro/playwright +``` + + + + +```bash +KNAPSACK_PRO_CI_NODE_TOTAL=N \ +KNAPSACK_PRO_CI_NODE_INDEX=N-1 \ +KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ +npx @knapsack-pro/playwright +``` + + + + + + + + +### Buildkite + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_buildkite) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +Remember to configure the `parallelism` parameter in your build step. + + + + +```bash +npx @knapsack-pro/playwright +``` + + + + +```bash +npx @knapsack-pro/playwright +``` + + + + +```bash +npx @knapsack-pro/playwright +``` + + + + +When using the `docker-compose` plugin on Buildkite, you have to pass the following environment variables: + +```yaml +steps: + - label: "Test" + parallelism: 2 + plugins: + - docker-compose#3.0.3: + run: app + # highlight-next-line + command: npx @knapsack-pro/playwright + config: docker-compose.test.yml + # highlight-start + env: + - BUILDKITE + - BUILDKITE_PARALLEL_JOB_COUNT + - BUILDKITE_PARALLEL_JOB + - BUILDKITE_BUILD_NUMBER + - BUILDKITE_COMMIT + - BUILDKITE_BRANCH + - BUILDKITE_BUILD_AUTHOR + - BUILDKITE_BUILD_CREATOR + # highlight-end +``` + +Here you can find an article on [how to set up a new pipeline for your project in Buildkite and configure Knapsack Pro](https://docs.knapsackpro.com/2017/auto-balancing-7-hours-tests-between-100-parallel-jobs-on-ci-buildkite-example). + +You can also check out the following example repositories for Ruby on Rails projects: + +- [Buildkite Rails Parallel Example with Knapsack Pro](https://github.com/KnapsackPro/buildkite-rails-parallel-example-with-knapsack_pro) +- [Buildkite Rails Docker Parallel Example with Knapsack Pro](https://github.com/KnapsackPro/buildkite-rails-docker-parallel-example-with-knapsack_pro) + + + + + +### CircleCI + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_circleci) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +Remember to add additional parallel containers in the CircleCI settings. + +```yaml title=".circleci/config.yml" +jobs: + build: + # highlight-next-line + parallelism: 2 + + steps: + - checkout + + # ... + + # highlight-start + - run: + name: playwright with @knapsack-pro/playwright + command: npx @knapsack-pro/playwright + # highlight-end +``` + +Here you can find an example of a [Rails project config on CircleCI 2.0](https://docs.knapsackpro.com/2017/circleci-2-0-capybara-feature-specs-selenium-webdriver-with-chrome-headless). + + + + + +### Cirrus CI + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_cirrusci) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +Configure the number of parallel CI nodes with the [matrix modification](https://cirrus-ci.org/guide/writing-tasks/#matrix-modification): + +```yaml title=".cirrus.yml" +task: + environment: + KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT: ENCRYPTED[KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT] + matrix: + name: CI Node 0 + name: CI Node 1 + name: CI Node 2 + test_script: + - npx @knapsack-pro/playwright +``` + +Remember to set up the `KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT` as an [encrypted variable](https://cirrus-ci.org/guide/writing-tasks/#encrypted-variables). + +Here is an example of a [`.cirrus.yml` configuration file](https://cirrus-ci.org/examples/#ruby) for a Ruby project. + + + + + +### CloudBees CodeShip + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_codeship) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +For each [parallel pipeline](https://docs.cloudbees.com/docs/cloudbees-codeship/latest/basic-builds-and-configuration/parallel-tests#using-parallel-test-pipelines), define: + +- [`KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT`](../reference.md#knapsack_pro_test_suite_token_playwright) +- [`KNAPSACK_PRO_CI_NODE_TOTAL`](../reference.md#knapsack_pro_ci_node_total) +- [`KNAPSACK_PRO_CI_NODE_INDEX`](../reference.md#knapsack_pro_ci_node_index) + + + + +```bash +KNAPSACK_PRO_CI_NODE_TOTAL=N \ +KNAPSACK_PRO_CI_NODE_INDEX=0 \ +KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ +npx @knapsack-pro/playwright +``` + + + + +```bash +KNAPSACK_PRO_CI_NODE_TOTAL=N \ +KNAPSACK_PRO_CI_NODE_INDEX=1 \ +KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ +npx @knapsack-pro/playwright +``` + + + + +```bash +KNAPSACK_PRO_CI_NODE_TOTAL=N \ +KNAPSACK_PRO_CI_NODE_INDEX=N-1 \ +KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ +npx @knapsack-pro/playwright +``` + + + + +Consider moving the `KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT` to the _Environment_ page of your project settings in CodeShip. + + + + + +### Codefresh + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_codefresh) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +Define in `.codefresh/codefresh.yml`: + +- [`KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT`](../reference.md#knapsack_pro_test_suite_token_playwright) +- [`KNAPSACK_PRO_CI_NODE_TOTAL`](../reference.md#knapsack_pro_ci_node_total) +- [`KNAPSACK_PRO_CI_NODE_INDEX`](../reference.md#knapsack_pro_ci_node_index) + - In the `matrix` section, list all the `KNAPSACK_PRO_CI_NODE_INDEX`es (from `0` to `KNAPSACK_PRO_CI_NODE_TOTAL-1`). + +Remember to configure the YAML file path on Codefresh: _Pipelines > Settings (cog icon next to the pipeline) > Workflow Tab (horizontal menu on the top) > Path to YAML > `./.codefresh/codefresh.yml`_. + +Here's an example config: + + + + +```yaml title=".codefresh/codefresh.yml" +version: "1.0" + +stages: + - "clone" + - "build" + - "tests" + +steps: + main_clone: + type: "git-clone" + description: "Cloning main repository..." + repo: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}" + revision: "${{CF_BRANCH}}" + stage: "clone" + BuildTestDockerImage: + title: Building Test Docker image + type: build + arguments: + image_name: "${{CF_ACCOUNT}}/${{CF_REPO_NAME}}-test" + tag: "${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}" + dockerfile: Test.Dockerfile + stage: "build" + + run_tests: + stage: "tests" + image: "${{BuildTestDockerImage}}" + working_directory: /src + fail_fast: false + environment: + # highlight-next-line + - KNAPSACK_PRO_CI_NODE_TOTAL=2 + # highlight-start + matrix: + environment: + - KNAPSACK_PRO_CI_NODE_INDEX=0 + - KNAPSACK_PRO_CI_NODE_INDEX=1 + # highlight-end + commands: + # highlight-start + - npx @knapsack-pro/playwright + # highlight-end +``` + +Consider setting up the `KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT` on the Codefresh dashboard: _Pipelines > Settings (cog icon next to the pipeline) > Variables Tab (vertical menu on the right-hand side)_. + + + + + +```bash title="Test.Dockerfile" +FROM node:10.13 + +RUN apt-get update && \ + apt-get install -y \ + python3-dev \ + python3-pip + +# Install AWS CLI +RUN pip3 install awscli + +# Install Codefresh CLI +RUN wget https://github.com/codefresh-io/cli/releases/download/v0.31.1/codefresh-v0.31.1-alpine-x64.tar.gz +RUN tar -xf codefresh-v0.31.1-alpine-x64.tar.gz -C /usr/local/bin/ + +COPY . /src + +WORKDIR /src + +RUN npm install +``` + + + + + + + + +### GitHub Actions + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_githubactions) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +Define in `.github/workflows/main.yaml`: + +- [`KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT`](../reference.md#knapsack_pro_test_suite_token_playwright) using secrets (*Actions* & *Dependabot*) as described in [GitHub Actions' docs](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) +- [`KNAPSACK_PRO_CI_NODE_TOTAL`](../reference.md#knapsack_pro_ci_node_total) using the [`matrix` property](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) +- [`KNAPSACK_PRO_CI_NODE_INDEX`](../reference.md#knapsack_pro_ci_node_index) using the [`matrix` property](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) + +Here's an example config: + +```yaml title=".github/workflows/main.yaml" +name: Main + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + # highlight-start + matrix: + node-version: [18.x] + ci_node_total: [2] + ci_node_index: [0, 1] + # highlight-end + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install and Build + run: | + npm install + npm run build --if-present + + # highlight-start + - name: Run tests + env: + KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT }} + KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }} + KNAPSACK_PRO_CI_NODE_INDEX: ${{ matrix.ci_node_index }} + run: | + npx @knapsack-pro/playwright + # highlight-end +``` + + + + + +### GitLab CI + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_gitlabci) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +#### GitLab CI >= 11.5 + +```yaml +test: + parallel: 2 + + script: + - KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN npx @knapsack-pro/playwright +``` + +See also [how to configure running parallel CI nodes in GitLab](https://docs.gitlab.com/ee/ci/yaml/#parallel). + +#### GitLab CI < 11.5 + +Define in `.gitlab-ci.yml`: + +- [`KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT`](../reference.md#knapsack_pro_test_suite_token_playwright) +- [`KNAPSACK_PRO_CI_NODE_TOTAL`](../reference.md#knapsack_pro_ci_node_total) +- [`KNAPSACK_PRO_CI_NODE_INDEX`](../reference.md#knapsack_pro_ci_node_index) + +Here's an example configuration for 2 parallel jobs: + +```yaml title=".gitlab-ci.yml" +stages: + - test + +# highlight-start +variables: + KNAPSACK_PRO_CI_NODE_TOTAL: 2 +# highlight-end + +test_ci_first_node: + stage: test + script: + # highlight-start + - export KNAPSACK_PRO_CI_NODE_INDEX=0 + - KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN npx @knapsack-pro/playwright + # highlight-end + +test_ci_second_node: + stage: test + script: + # highlight-start + - export KNAPSACK_PRO_CI_NODE_INDEX=1 + - KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN npx @knapsack-pro/playwright + # highlight-end +``` + +Remember to set up the `KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT` as [Secret Variables](https://gitlab.com/help/ci/variables/README.md#secret-variables) in GitLab CI: _Settings > CI/CD Pipelines > Secret Variables_. + + + + + +### Heroku CI + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_herokuci) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +Define in `app.json`: + +- [`KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT`](../reference.md#knapsack_pro_test_suite_token_playwright) +- `quantity`: number of parallel dynos +- `test`: the Knapsack Pro command + +```json title="app.json" +{ + "environments": { + "test": { + "formation": { + "test": { + // highlight-next-line + "quantity": 2 + } + }, + "addons": [ + "heroku-postgresql:in-dyno", + "heroku-redis:in-dyno" + ], + // highlight-start + "scripts": { + "test": "npx @knapsack-pro/playwright" + }, + "env": { + "KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT": "MY_PLAYWRIGHT_API_TOKEN" + } + // highlight-end + } + } +} +``` + +Remember to set up the `KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT` outside of `app.json` in your Heroku CI pipeline's settings. + + + + + +### Jenkins + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_jenkins) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +In order to run parallel jobs with Jenkins you should use Jenkins Pipeline as described in [Parallelism and Distributed Builds with Jenkins](https://www.cloudbees.com/blog/parallelism-and-distributed-builds-jenkins). + +Here is an example of a `Jenkinsfile` working with Jenkins Pipeline: + +```groovy +timeout(time: 60, unit: 'MINUTES') { + node() { + stage('Checkout') { + checkout([/* checkout code from git */]) + + // determine git commit hash because we need to pass it to Knapsack Pro + COMMIT_HASH = sh(returnStdout: true, script: 'git rev-parse HEAD').trim() + + stash 'source' + } + } + + // highlight-next-line + def num_nodes = 4; // define your total number of CI nodes (how many parallel jobs will be executed) + def nodes = [:] + + for (int i = 0; i < num_nodes; i++) { + def index = i; + nodes["ci_node_${i}"] = { + node() { + stage('Setup') { + unstash 'source' + // other setup steps + } + + // highlight-start + def knapsack_options = """\ + KNAPSACK_PRO_CI_NODE_TOTAL=${num_nodes}\ + KNAPSACK_PRO_CI_NODE_INDEX=${index}\ + KNAPSACK_PRO_COMMIT_HASH=${COMMIT_HASH}\ + KNAPSACK_PRO_BRANCH=${env.BRANCH_NAME}\ + KNAPSACK_PRO_CI_NODE_BUILD_ID=${env.BUILD_TAG}\ + KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN + """ + + stage('Run tests') { + sh """${knapsack_options} npx @knapsack-pro/playwright""" + } + // highlight-end + } + } + } + + parallel nodes // run CI nodes in parallel +} +``` + +Consider setting up the `KNAPSACK_PRO_TEST_SUITE_TOKEN_*` as global environment variables in Jenkins. + + + + + +### Semaphore CI + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_semaphoreci) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +Define in `.semaphore/semaphore.yml`: + +- [`KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT`](../reference.md#knapsack_pro_test_suite_token_playwright) +- `parallelism` + +Here's an example config: + +```yaml title=".semaphore/semaphore.yml" +version: v1.0 + +name: My app + +agent: + machine: + type: e1-standard-2 + os_image: ubuntu1804 + +blocks: + - name: Playwright tests + task: + env_vars: + # highlight-start + - name: KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT + value: MY_PLAYWRIGHT_API_TOKEN + # highlight-end + prologue: + commands: + - checkout + - nvm install --lts hydrogen + - sem-version node --lts hydrogen + + # highlight-start + jobs: + - name: Run tests with Knapsack Pro + parallelism: 2 + commands: + - npx @knapsack-pro/playwright + # highlight-end +``` + +Remember to set up `KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT` as a [secret](https://docs.semaphoreci.com/using-semaphore/secrets). + + + + + +### Travis CI + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_travisci) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +Define in `.travis.yml`: + +- [`KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT`](../reference.md#knapsack_pro_test_suite_token_playwright) +- [`KNAPSACK_PRO_CI_NODE_TOTAL`](../reference.md#knapsack_pro_ci_node_total) +- [`KNAPSACK_PRO_CI_NODE_INDEX`](../reference.md#knapsack_pro_ci_node_index) as [jobs](https://docs.travis-ci.com/user/speeding-up-the-build/#parallelize-builds-across-virtual-machines) + +```yaml +script: + - "npx @knapsack-pro/playwright" + +env: + global: + - KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN + - KNAPSACK_PRO_CI_NODE_TOTAL=3 + jobs: + - KNAPSACK_PRO_CI_NODE_INDEX=0 + - KNAPSACK_PRO_CI_NODE_INDEX=1 + - KNAPSACK_PRO_CI_NODE_INDEX=2 +``` + +Remember to set up `KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT` as tokens in the Travis settings to avoid exposing them in the build logs. + +You can find more info about the global and matrix env configuration in the [Travis' docs](https://docs.travis-ci.com/user/customizing-the-build/#build-matrix). + + + + + +### Other CI provider + +[Generate an API token](https://knapsackpro.com/sessions?utm_source=docs_knapsackpro&utm_medium=page&utm_campaign=knapsack-pro-playwright&utm_content=installation_guide_otherci) for each Knapsack Pro command on the CI. Each command needs its own API token to treat every test suite as a separate entity. + +Define the following global environment variables on your CI server: + +- [`KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT`](../reference.md#knapsack_pro_test_suite_token_playwright) +- [`KNAPSACK_PRO_CI_NODE_TOTAL`](../reference.md#knapsack_pro_ci_node_total) +- [`KNAPSACK_PRO_CI_NODE_INDEX`](../reference.md#knapsack_pro_ci_node_index) +- [`KNAPSACK_PRO_CI_NODE_BUILD_ID`](../reference.md#knapsack_pro_ci_node_build_id) + + + + +```bash +KNAPSACK_PRO_CI_NODE_TOTAL=N \ +KNAPSACK_PRO_CI_NODE_INDEX=0 \ +KNAPSACK_PRO_CI_NODE_BUILD_ID=MY_BUILD_ID \ +KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ +npx @knapsack-pro/playwright +``` + + + + +```bash +KNAPSACK_PRO_CI_NODE_TOTAL=N \ +KNAPSACK_PRO_CI_NODE_INDEX=1 \ +KNAPSACK_PRO_CI_NODE_BUILD_ID=MY_BUILD_ID \ +KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ +npx @knapsack-pro/playwright +``` + + + + +```bash +KNAPSACK_PRO_CI_NODE_TOTAL=N \ +KNAPSACK_PRO_CI_NODE_INDEX=N-1 \ +KNAPSACK_PRO_CI_NODE_BUILD_ID=MY_BUILD_ID \ +KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ +npx @knapsack-pro/playwright +``` + + + + + + + + +### Verify that everything works + +Push a new commit to your repository and visit your [dashboard](https://knapsackpro.com/sessions) to make sure all your CI nodes were recorded successfully in _Show build metrics > Show (build)_. + +**Congratulations!** Now that Knapsack Pro knows the statistics of your test suite, your CI builds will be parallelized optimally. + +### Next up + +Make sure you check out the [Reference](../reference.md) page to fine-tune your Knapsack Pro setup. + + + +## Need help? + +[Get in touch!](https://knapsackpro.com/contact) + +We have helped TONS of teams and seen TONS of projects. We know each test suite is a different beast and we'd be happy to help you set up Knapsack Pro. diff --git a/docusaurus/docs/playwright/reference.md b/docusaurus/docs/playwright/reference.md new file mode 100644 index 00000000..ca6c667b --- /dev/null +++ b/docusaurus/docs/playwright/reference.md @@ -0,0 +1,174 @@ +--- +pagination_next: null +pagination_prev: null +toc_max_heading_level: 2 +--- + +# Playwright Reference + +You can configure things in two ways: + +- Command-line arguments for the test runner +- Environment variables for Knapsack Pro or Node + +Unless specified otherwise, everything on this page is environment variables. + +## Command-line arguments + +You can pass all the [supported Playwright CLI options](https://playwright.dev/docs/test-cli) as command-line arguments: + +```bash +npx @knapsack-pro/playwright --coverage +``` + +## `KNAPSACK_PRO_BRANCH` + +Git branch under test. + +You don't need to set it if either: + +- Your CI is one of the [supported CIs](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/core/src/ci-providers) +- Your CI has git installed so that Knapsack Pro can retrieve it + +In some cases, particularly for pull request merge commits or if the CI provider checks out a specific git commit during the build process, Git might only expose `HEAD` instead of the actual branch name. + +## `KNAPSACK_PRO_CI_NODE_BUILD_ID` + +Unique ID that identifies a CI build. It must be the same for all the parallel CI nodes. + +Default: Knapsack Pro will take it from the CI environment (see [supported CIs](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/core/src/ci-providers)) + +If your CI is not supported, you may generate a build ID with `KNAPSACK_PRO_CI_NODE_BUILD_ID=$(openssl rand -base64 32)` and make it available to all parallel nodes. + +## `KNAPSACK_PRO_CI_NODE_INDEX` + +Index of current CI node (first should be 0, second should be 1, etc.). + +Default: Knapsack Pro will take it from the CI environment (see [supported CIs](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/core/src/ci-providers)) + +If your CI is not supported, you need to set it manually. + +## `KNAPSACK_PRO_CI_NODE_RETRY_COUNT` + +A retry count of the current CI node in case of a single node/job retry. + +There is no need to set this for the following CI providers that are supported out of the box: + +* GitHub Actions +* Buildkite + +For other CI providers: + +If you use `KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`, you need to set `KNAPSACK_PRO_CI_NODE_RETRY_COUNT=1` when retrying a single node to disable Fallback Mode. Otherwise, the CI node would use a different (fallback) split and run a different subset of tests when the API cannot be reached. + +Default: `0` (or an environment variable for supported CI providers) + +Available: + +- `0`: Fallback Mode is enabled +- `> 0`: Fallback Mode is disabled and Knapsack Pro raises an error if the API cannot be reached + +## `KNAPSACK_PRO_CI_NODE_TOTAL` + +Total number of parallel CI nodes. + +Default: Knapsack Pro will take it from the CI environment (see [supported CIs](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/core/src/ci-providers)) + +If your CI is not supported, you need to set it manually. + +## `KNAPSACK_PRO_COMMIT_HASH` + +Hash of the commit under test. + +You don't need to set it if either: + +- Your CI is one of the [supported CIs](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/core/src/ci-providers) +- Your CI has git installed so that Knapsack Pro can retrieve it + +## `KNAPSACK_PRO_ENDPOINT` (Internal) + +Default: `https://api.knapsackpro.com` + +## `KNAPSACK_PRO_FIXED_QUEUE_SPLIT` + +Dynamic or fixed tests split when retrying a CI build. + +Default: automagically set to the correct value for your [CI provider](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/core/src/ci-providers) + +Available: + +- `false`: generate a new split when `KNAPSACK_PRO_CI_NODE_BUILD_ID` changes (see what Knapsack Pro uses as `ciNodeBuildId` for your [CI provider](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/core/src/ci-providers)) +- `true`: if the triplet `(branch name, commit hash, number of nodes)` was already split in a previous build use the same split, otherwise generate a new split + +Recommended: + +- `true` when your CI allows retrying single CI nodes (e.g., Buildkite, GitHub Actions) or if your CI nodes are spot instances/preemptible +- `true` when your CI uses the same `KNAPSACK_PRO_CI_NODE_BUILD_ID` on retries (e.g., GitHub Actions, Travis, CodeShip) +- `false` otherwise + +## `KNAPSACK_PRO_LOG_LEVEL` + +Default: `info` + +Available: + +- `error`: critical errors +- `warn`: warnings (e.g. Fallback Mode has started) +- `info`: Knapsack Pro API request response body +- `verbose` +- `debug`: Knapsack Pro API request headers and body +- `silly` + +## `KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE` + +File containing the list of relative paths from the `root` directory of tests to run. + +Default: `undefined` + +Example: + +```bash +KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE=__tests__/fixtures/list.txt + +# ✅ list.txt +__tests__/a.test.js +__tests__/b.test.js +__tests__/c.test.js + +# ⛔️ list.txt +/home/user123/project/__tests__/a.test.js +/home/user123/project/__tests__/b.test.js +/home/user123/project/__tests__/c.test.js +``` + +## `KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT` + +API token required to run Knapsack Pro. + +Each Knapsack Pro command defined on CI should use an individual API token. + +Example: + +```bash +KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ +KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE="user_tests.txt" \ + npx @knapsack-pro/playwright + +KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_OTHER_PLAYWRIGHT_API_TOKEN \ +KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE="admin_tests.txt" \ + npx @knapsack-pro/playwright +``` + +## `KNAPSACK_PRO_USER_SEAT` + +A user name that started the CI build. It is usually the same person that made the git commit. + +You don't need to set it if: + +- Your CI is one of the [supported CIs](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/core/src/ci-providers), and we can read the user seat for the given CI provider. + +Examples: + +```bash +KNAPSACK_PRO_USER_SEAT="John Doe " +``` diff --git a/docusaurus/docs/playwright/troubleshooting.md b/docusaurus/docs/playwright/troubleshooting.md new file mode 100644 index 00000000..eafe4962 --- /dev/null +++ b/docusaurus/docs/playwright/troubleshooting.md @@ -0,0 +1,34 @@ +--- +pagination_next: null +pagination_prev: null +--- + +# Playwright Troubleshooting + +## JavaScript heap out of memory + +You can increase the memory available to Node with [`--max_old_space_size`](https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes): + +```bash +export NODE_OPTIONS=--max_old_space_size=4096 + +npx @knapsack-pro/playwright +``` + +## Debug Knapsack Pro on your development environment/machine + +To reproduce what Knapsack Pro executed on a specific CI node, check out the same branch and run: + +```bash +KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_TOKEN \ +KNAPSACK_PRO_CI_NODE_INDEX=MY_INDEX \ +KNAPSACK_PRO_CI_NODE_TOTAL=MY_TOTAL \ +KNAPSACK_PRO_BRANCH=MY_BRANCH \ +KNAPSACK_PRO_COMMIT_HASH=MY_COMMIT \ +KNAPSACK_PRO_CI_NODE_BUILD_ID=MY_BUILD_ID \ +KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true \ +KNAPSACK_PRO_TEST_FILE_PATTERN="**/*.{test,spec}.?(c|m)[jt]s?(x)" \ +npx @knapsack-pro/playwright +``` + +`KNAPSACK_PRO_CI_NODE_BUILD_ID` must be the same as the CI build you are trying to reproduce (if it helps, take a look at what Knapsack Pro uses as `ciNodeBuildId` for your [CI provider](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/core/src/ci-providers)). diff --git a/docusaurus/docs/troubleshooting/index.mdx b/docusaurus/docs/troubleshooting/index.mdx index a7b57694..5f92ffa3 100644 --- a/docusaurus/docs/troubleshooting/index.mdx +++ b/docusaurus/docs/troubleshooting/index.mdx @@ -3,10 +3,11 @@ pagination_prev: null pagination_next: null --- -import ruby from "@site/static/img/ruby.png" +import Playwright from "@site/static/img/playwright.svg" +import Vitest from "@site/static/img/vitest.svg" import cypress from "@site/static/img/cypress.jpg" import jest from "@site/static/img/jest.jpg" -import Vitest from "@site/static/img/vitest.svg" +import ruby from "@site/static/img/ruby.png" # Troubleshooting @@ -36,4 +37,9 @@ If you are utilizing two CI providers simultaneously, for example, CircleCI and

Vitest

+ + +
+

Playwright

+
diff --git a/docusaurus/sidebars.ts b/docusaurus/sidebars.ts index 09c1d5ee..32080cb4 100644 --- a/docusaurus/sidebars.ts +++ b/docusaurus/sidebars.ts @@ -273,6 +273,44 @@ const sidebars: SidebarsConfig = { }, ], }, + { + type: "category", + label: "Playwright", + collapsible: true, + collapsed: true, + items: [ + { + type: "doc", + label: "Installation", + id: "playwright/guide/index", + }, + { + type: "doc", + label: "Reference", + id: "playwright/reference", + }, + { + type: "doc", + label: "Troubleshooting", + id: "playwright/troubleshooting", + }, + { + type: "doc", + label: "Cookbook", + id: "playwright/cookbook", + }, + { + type: "link", + label: "GitHub", + href: "https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/playwright", + }, + { + type: "link", + label: "Changelog", + href: "https://github.com/KnapsackPro/knapsack-pro-js/blob/main/packages/playwright/CHANGELOG.md", + }, + ], + }, { type: "category", label: "Write your integration", diff --git a/docusaurus/src/css/custom.css b/docusaurus/src/css/custom.css index ebf0193e..70a09e1f 100644 --- a/docusaurus/src/css/custom.css +++ b/docusaurus/src/css/custom.css @@ -128,7 +128,7 @@ li { .grid-4 { display: grid; - grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; margin-bottom: var(--ifm-paragraph-margin-bottom); } diff --git a/docusaurus/static/img/playwright.svg b/docusaurus/static/img/playwright.svg new file mode 100644 index 00000000..7b3ca7d6 --- /dev/null +++ b/docusaurus/static/img/playwright.svg @@ -0,0 +1,9 @@ + + + + + + + + + From 8560b279be7cefb8ebc7011016501faa60759961 Mon Sep 17 00:00:00 2001 From: 3v0k4 Date: Tue, 16 Dec 2025 17:40:03 +0100 Subject: [PATCH 2/2] docs(playwright): fixes --- docusaurus/docs/playwright/cookbook.md | 10 ++-- docusaurus/docs/playwright/guide/index.mdx | 48 +++++++++---------- docusaurus/docs/playwright/reference.md | 6 +-- docusaurus/docs/playwright/troubleshooting.md | 4 +- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/docusaurus/docs/playwright/cookbook.md b/docusaurus/docs/playwright/cookbook.md index 326779f9..9bb0f947 100644 --- a/docusaurus/docs/playwright/cookbook.md +++ b/docusaurus/docs/playwright/cookbook.md @@ -11,13 +11,13 @@ To run a subset of your test suite you can use the `KNAPSACK_PRO_TEST_FILE_LIST_ - [`KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE`](reference.md#knapsack_pro_test_file_list_source_file) -## Test coverage +## Reporters -Use the [blob reporter](https://playwright.dev/docs/test-reporters#blob-reporter) without specifying an `outputDir` or `outputFile`. Later, execute `playwright --merge-reports` to output coverage or any aggregated reports you need (e.g., `json`): +Use the [blob reporter](https://playwright.dev/docs/test-reporters#blob-reporter) without specifying an `outputDir` or `outputFile`. Later, execute `playwright --merge-reports` to output any aggregated reports you need (e.g., `json`): ```bash -npx @knapsack-pro/playwright --coverage --reporter=blob,@knapsack-pro/playwright/reporters/batch -npx playwright merge-reports --coverage +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch +npx playwright merge-reports --reporter=list blob-report/ ``` -Knapsack Pro generates one blob file per batch of tests executed named as follows: `blob-report/TODO` (e.g., `TODO`). +Knapsack Pro generates one blob file per batch of tests executed named as follows: `blob-report/report-[HASH].zip` (e.g., `blob-report/report-24ad5ce.zip`). diff --git a/docusaurus/docs/playwright/guide/index.mdx b/docusaurus/docs/playwright/guide/index.mdx index a8f229d7..e393ace5 100644 --- a/docusaurus/docs/playwright/guide/index.mdx +++ b/docusaurus/docs/playwright/guide/index.mdx @@ -94,7 +94,7 @@ Remember to configure the number of parallel CI nodes in AppVeyor. KNAPSACK_PRO_CI_NODE_TOTAL=N \ KNAPSACK_PRO_CI_NODE_INDEX=0 \ KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` @@ -104,7 +104,7 @@ npx @knapsack-pro/playwright KNAPSACK_PRO_CI_NODE_TOTAL=N \ KNAPSACK_PRO_CI_NODE_INDEX=1 \ KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` @@ -114,7 +114,7 @@ npx @knapsack-pro/playwright KNAPSACK_PRO_CI_NODE_TOTAL=N \ KNAPSACK_PRO_CI_NODE_INDEX=N-1 \ KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` @@ -134,21 +134,21 @@ Remember to configure the `parallelism` parameter in your build step. ```bash -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` ```bash -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` ```bash -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` @@ -164,7 +164,7 @@ steps: - docker-compose#3.0.3: run: app # highlight-next-line - command: npx @knapsack-pro/playwright + command: npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch config: docker-compose.test.yml # highlight-start env: @@ -210,7 +210,7 @@ jobs: # highlight-start - run: name: playwright with @knapsack-pro/playwright - command: npx @knapsack-pro/playwright + command: npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch # highlight-end ``` @@ -235,7 +235,7 @@ task: name: CI Node 1 name: CI Node 2 test_script: - - npx @knapsack-pro/playwright + - npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` Remember to set up the `KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT` as an [encrypted variable](https://cirrus-ci.org/guide/writing-tasks/#encrypted-variables). @@ -263,7 +263,7 @@ For each [parallel pipeline](https://docs.cloudbees.com/docs/cloudbees-codeship/ KNAPSACK_PRO_CI_NODE_TOTAL=N \ KNAPSACK_PRO_CI_NODE_INDEX=0 \ KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` @@ -273,7 +273,7 @@ npx @knapsack-pro/playwright KNAPSACK_PRO_CI_NODE_TOTAL=N \ KNAPSACK_PRO_CI_NODE_INDEX=1 \ KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` @@ -283,7 +283,7 @@ npx @knapsack-pro/playwright KNAPSACK_PRO_CI_NODE_TOTAL=N \ KNAPSACK_PRO_CI_NODE_INDEX=N-1 \ KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` @@ -353,7 +353,7 @@ steps: # highlight-end commands: # highlight-start - - npx @knapsack-pro/playwright + - npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch # highlight-end ``` @@ -442,7 +442,7 @@ jobs: KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }} KNAPSACK_PRO_CI_NODE_INDEX: ${{ matrix.ci_node_index }} run: | - npx @knapsack-pro/playwright + npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch # highlight-end ``` @@ -461,7 +461,7 @@ test: parallel: 2 script: - - KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN npx @knapsack-pro/playwright + - KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` See also [how to configure running parallel CI nodes in GitLab](https://docs.gitlab.com/ee/ci/yaml/#parallel). @@ -490,7 +490,7 @@ test_ci_first_node: script: # highlight-start - export KNAPSACK_PRO_CI_NODE_INDEX=0 - - KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN npx @knapsack-pro/playwright + - KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch # highlight-end test_ci_second_node: @@ -498,7 +498,7 @@ test_ci_second_node: script: # highlight-start - export KNAPSACK_PRO_CI_NODE_INDEX=1 - - KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN npx @knapsack-pro/playwright + - KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch # highlight-end ``` @@ -534,7 +534,7 @@ Define in `app.json`: ], // highlight-start "scripts": { - "test": "npx @knapsack-pro/playwright" + "test": "npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch" }, "env": { "KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT": "MY_PLAYWRIGHT_API_TOKEN" @@ -596,7 +596,7 @@ timeout(time: 60, unit: 'MINUTES') { """ stage('Run tests') { - sh """${knapsack_options} npx @knapsack-pro/playwright""" + sh """${knapsack_options} npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch""" } // highlight-end } @@ -653,7 +653,7 @@ blocks: - name: Run tests with Knapsack Pro parallelism: 2 commands: - - npx @knapsack-pro/playwright + - npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch # highlight-end ``` @@ -675,7 +675,7 @@ Define in `.travis.yml`: ```yaml script: - - "npx @knapsack-pro/playwright" + - "npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch" env: global: @@ -714,7 +714,7 @@ KNAPSACK_PRO_CI_NODE_TOTAL=N \ KNAPSACK_PRO_CI_NODE_INDEX=0 \ KNAPSACK_PRO_CI_NODE_BUILD_ID=MY_BUILD_ID \ KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` @@ -725,7 +725,7 @@ KNAPSACK_PRO_CI_NODE_TOTAL=N \ KNAPSACK_PRO_CI_NODE_INDEX=1 \ KNAPSACK_PRO_CI_NODE_BUILD_ID=MY_BUILD_ID \ KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` @@ -736,7 +736,7 @@ KNAPSACK_PRO_CI_NODE_TOTAL=N \ KNAPSACK_PRO_CI_NODE_INDEX=N-1 \ KNAPSACK_PRO_CI_NODE_BUILD_ID=MY_BUILD_ID \ KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` diff --git a/docusaurus/docs/playwright/reference.md b/docusaurus/docs/playwright/reference.md index ca6c667b..f60d27e3 100644 --- a/docusaurus/docs/playwright/reference.md +++ b/docusaurus/docs/playwright/reference.md @@ -18,7 +18,7 @@ Unless specified otherwise, everything on this page is environment variables. You can pass all the [supported Playwright CLI options](https://playwright.dev/docs/test-cli) as command-line arguments: ```bash -npx @knapsack-pro/playwright --coverage +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch --retries 2 ``` ## `KNAPSACK_PRO_BRANCH` @@ -152,11 +152,11 @@ Example: ```bash KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_PLAYWRIGHT_API_TOKEN \ KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE="user_tests.txt" \ - npx @knapsack-pro/playwright + npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch KNAPSACK_PRO_TEST_SUITE_TOKEN_PLAYWRIGHT=MY_OTHER_PLAYWRIGHT_API_TOKEN \ KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE="admin_tests.txt" \ - npx @knapsack-pro/playwright + npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` ## `KNAPSACK_PRO_USER_SEAT` diff --git a/docusaurus/docs/playwright/troubleshooting.md b/docusaurus/docs/playwright/troubleshooting.md index eafe4962..ec46017f 100644 --- a/docusaurus/docs/playwright/troubleshooting.md +++ b/docusaurus/docs/playwright/troubleshooting.md @@ -12,7 +12,7 @@ You can increase the memory available to Node with [`--max_old_space_size`](http ```bash export NODE_OPTIONS=--max_old_space_size=4096 -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` ## Debug Knapsack Pro on your development environment/machine @@ -28,7 +28,7 @@ KNAPSACK_PRO_COMMIT_HASH=MY_COMMIT \ KNAPSACK_PRO_CI_NODE_BUILD_ID=MY_BUILD_ID \ KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true \ KNAPSACK_PRO_TEST_FILE_PATTERN="**/*.{test,spec}.?(c|m)[jt]s?(x)" \ -npx @knapsack-pro/playwright +npx @knapsack-pro/playwright --reporter=blob,@knapsack-pro/playwright/reporters/batch ``` `KNAPSACK_PRO_CI_NODE_BUILD_ID` must be the same as the CI build you are trying to reproduce (if it helps, take a look at what Knapsack Pro uses as `ciNodeBuildId` for your [CI provider](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/core/src/ci-providers)).