---
title: End-to-end testing
description: Learn how to run end-to-end tests on your Hydrogen storefront deployment.
source_url:
  html: >-
    https://shopify.dev/docs/storefronts/headless/hydrogen/debugging/end-to-end-testing
  md: >-
    https://shopify.dev/docs/storefronts/headless/hydrogen/debugging/end-to-end-testing.md
api_name: hydrogen
---

# End-to-end testing

Learn how to run end-to-end tests against your deployment in your CI/CD workflow by creating an authentication bypass token.

***

## Step 1: Generate the authentication bypass token

1. [Generate a deployment token](https://shopify.dev/docs/storefronts/headless/hydrogen/deployments/custom-ci-cd) in the Shopify admin.

2. Modify your CI/CD file to include the [deploy](https://shopify.dev/docs/api/shopify-cli/hydrogen/hydrogen-deploy) command.

   ## Terminal

   ```sh
   npx shopify hydrogen deploy --auth-bypass-token --token $SHOPIFY_HYDROGEN_DEPLOYMENT_TOKEN
   ```

3. The command outputs a file named `h2_deploy_log.json`, which contains the deployment URL and the authentication bypass token that you can feed into your end-to-end testing system.

**Note:**

Authentication bypass tokens are supported only on the Oxygen deployment URL returned in `h2_deploy_log.json` (for example, `*.myshopify.dev`). They aren't supported on custom domains.

### Token duration

By default, tokens are valid for two hours. You can modify this duration by supplying the `--auth-bypass-token-duration` flag to the `deploy` command. The duration can be set to any whole number of hours from 1 to 12.

## Terminal

```sh
npx shopify hydrogen deploy --auth-bypass-token --auth-bypass-token-duration=5 --token $SHOPIFY_HYDROGEN_DEPLOYMENT_TOKEN
```

### Example Git​Hub workflow

If you're using GitHub workflow files, then edit the deploy step per the following example. If you're using another CI/CD system, then refer to these [example workflows](https://shopify.dev/docs/storefronts/headless/hydrogen/deployments/custom-ci-cd#example-workflows).

## .github/workflows/oxygen-deployment.yml

```yml
...


jobs:
  deploy:
    ...
    steps:
      - name: Build and Publish to Oxygen
        id: deploy
        run:
          - npx shopify hydrogen deploy --auth-bypass-token --token $SHOPIFY_HYDROGEN_DEPLOYMENT_TOKEN


      - name: Run End-to-end Tests
        run: |
          export AUTH_BYPASS_TOKEN=$(jq -r '.authBypassToken' h2_deploy_log.json)
          export DEPLOYMENT_URL=$(jq -r '.url' h2_deploy_log.json)
          npm run e2e-test
```

Refer to a live example in the [Hydrogen Demo Store](https://github.com/Shopify/hydrogen-demo-store/blob/main/.github/workflows/oxygen-deployment-1000013955.yml).

***

## Step 2: Embed the authentication bypass token in the request header

Your end-to-end testing system must embed the token within the header before navigating to the deployment URL from `h2_deploy_log.json`. Authentication bypass tokens are supported only on that deployment URL, not on custom domains. If you send requests to a custom domain instead, redirects can prevent the `oxygen-auth-bypass-token` header from reaching Oxygen.

```sh
oxygen-auth-bypass-token: <auth-bypass-token>
```

***
