Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: run website tests against netlify deployment #6212

Merged
merged 3 commits into from Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chuckles in #5573

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
4 changes: 1 addition & 3 deletions packages/website/tests/index.spec.ts
Expand Up @@ -15,8 +15,6 @@ test.describe('Website', () => {
}
});
await page.goto('/');
expect(errorMessages).toStrictEqual([
"[error] Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message was only applicable to the local dev-server and is not shown to our users on production builds. A nice extra benefit of this approach is that our testing is more representative of our end UX

]);
expect(errorMessages).toStrictEqual([]);
});
});