Skip to content

Commit

Permalink
chore: run website tests against netlify deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed Feb 20, 2023
1 parent d816496 commit b0b3d63
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -179,26 +179,38 @@ jobs:
contents: read # to fetch code (actions/checkout)

name: Website tests
# We technically do not need to wait for build within the pipeline any more because the build we care about is happening within Netlify, however,
# it is highly likely that if the CI one fails, the Netlify one will as well, so in order to not waste unncessary Github Actions minutes/resources,
# we do still keep this requirement here.
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Install
uses: ./.github/actions/prepare-install
with:
node-version: ${{ env.PRIMARY_NODE_VERSION }}
- name: Build
uses: ./.github/actions/prepare-build

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Playwright tests
- name: Wait for Netlify deployment
uses: probablyup/wait-for-netlify-action@3.2.0
id: waitForDeployment
with:
site_id: '128d21c7-b2fe-45ad-b141-9878fcf5de3a'
env:
NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }}

- name: Run Playwright tests against the Netlify deployment
run: yarn playwright test --reporter=list
working-directory: packages/website
env:
PLAYWRIGHT_TEST_BASE_URL: ${{ steps.waitForDeployment.outputs.url }}

- if: always()
uses: actions/upload-artifact@v3
Expand Down
14 changes: 8 additions & 6 deletions packages/website/playwright.config.ts
Expand Up @@ -8,7 +8,7 @@ const config: PlaywrightTestConfig = {
retries: 0,
testDir: './tests',
use: {
baseURL: 'http://localhost:3000',
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL || 'http://localhost:3000',
trace: 'on-first-retry',
},
projects: [
Expand All @@ -19,11 +19,13 @@ const config: PlaywrightTestConfig = {
},
},
],
webServer: {
command: 'yarn start',
port: 3000,
reuseExistingServer: !process.env.CI,
},
webServer: process.env.PLAYWRIGHT_TEST_BASE_URL
? undefined
: {
command: 'yarn start',
port: 3000,
reuseExistingServer: !process.env.CI,
},
workers: process.env.CI ? 1 : undefined,
};

Expand Down

0 comments on commit b0b3d63

Please sign in to comment.