-
Notifications
You must be signed in to change notification settings - Fork 286
Create Playwright test harness #8
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d79c19b
added playwright test and github actions
HannahZhuSWE c51547d
added install sirv to github action
HannahZhuSWE 9c3f9cb
added readme file and reverted start script
HannahZhuSWE c5c9b59
changed start script and github links
HannahZhuSWE 53c9b9d
Update Test.README.md
HannahZhuSWE 29f093b
removed links from package.json and commented out stuff from playwrig…
HannahZhuSWE b59f5f8
Merge branch 'main' of https://github.com/HannahZhuSWE/vanilla-basic
HannahZhuSWE 06c242f
updated with recommendations
HannahZhuSWE 5c18442
changed pull_request to pull_request_target
HannahZhuSWE a1905aa
change github action to run on pull_request
HannahZhuSWE 2567d30
updated github action to run on all branches
HannahZhuSWE c74605e
updated comments and job name in github action
HannahZhuSWE File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: Playwright Tests | ||
|
|
||
| # Controls when the workflow will run | ||
| on: | ||
| # Triggers the workflow on push or pull request and nightly | ||
| push: | ||
| pull_request: | ||
| schedule: | ||
| # nightly | ||
| - cron: '0 0 * * *' | ||
|
|
||
| # Allows you to run this workflow manually from the Actions tab | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| playwright_tests: | ||
| # Runs on an ubuntu runner | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| node-version: [14.x, 16.x, 18.x] | ||
| # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/setup-node@v3 | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| - name: Install Playwright | ||
| run: npx playwright install --with-deps | ||
| - name: Install Sirv | ||
| run: npm install --g sirv-cli | ||
| - name: Run playwright tests | ||
| run: npm run playwright_test | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| node_modules/ | ||
| /test-results/ | ||
| /playwright-report/ | ||
| /playwright/.cache/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "name": "vanilla-basic", | ||
| "version": "1.0.0", | ||
| "scripts": { | ||
| "start": "sirv ./src public --cors --single --no-clear --port 8000", | ||
| "playwright_test" : "playwright test" | ||
| }, | ||
| "devDependencies": { | ||
| "@playwright/test": "^1.22.2" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import type { PlaywrightTestConfig } from '@playwright/test'; | ||
| import { devices } from '@playwright/test'; | ||
|
|
||
| /** | ||
| * Read environment variables from file. | ||
| * https://github.com/motdotla/dotenv | ||
| */ | ||
| // require('dotenv').config(); | ||
|
|
||
| /** | ||
| * See https://playwright.dev/docs/test-configuration. | ||
| */ | ||
| const config: PlaywrightTestConfig = { | ||
| testDir: './tests', | ||
| /* Maximum time one test can run for. */ | ||
| timeout: 30 * 1000, | ||
| expect: { | ||
| /** | ||
| * Maximum time expect() should wait for the condition to be met. | ||
| * For example in `await expect(locator).toHaveText();` | ||
| */ | ||
| timeout: 5000 | ||
| }, | ||
| /* Run tests in files in parallel */ | ||
| fullyParallel: true, | ||
| /* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
| forbidOnly: !!process.env.CI, | ||
| /* Retry on CI only */ | ||
| retries: process.env.CI ? 2 : 0, | ||
| /* Opt out of parallel tests on CI. */ | ||
| workers: process.env.CI ? 1 : undefined, | ||
| /* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
| reporter: 'html', | ||
| /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
| use: { | ||
| /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ | ||
| actionTimeout: 0, | ||
| /* Base URL to use in actions like `await page.goto('/')`. */ | ||
| baseURL: 'http://localhost:8000', | ||
|
|
||
| /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
| trace: 'on-first-retry', | ||
| }, | ||
|
|
||
| /* Configure projects for major browsers */ | ||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { | ||
| ...devices['Desktop Chrome'], | ||
| }, | ||
| }, | ||
|
|
||
| { | ||
| name: 'firefox', | ||
| use: { | ||
| ...devices['Desktop Firefox'], | ||
| }, | ||
| }, | ||
|
|
||
| { | ||
| name: 'webkit', | ||
| use: { | ||
| ...devices['Desktop Safari'], | ||
| }, | ||
| }, | ||
| ], | ||
|
|
||
| /* Run your local dev server before starting the tests */ | ||
| webServer: { | ||
| command: 'npm run start', | ||
| port: 8000, | ||
| } | ||
| }; | ||
|
|
||
| export default config; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Testing | ||
|
|
||
| To run playwright tests run `npm run playwright_test`. Note for the purposes of running playwright tests a package.json (and start script) was made. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
|
|
||
| test('basic test', async ({ page }) => { | ||
| await page.goto('/'); | ||
| await page.waitForSelector('h1'); | ||
| await expect(page.locator('h1')).toContainText('Vanilla JavaScript App'); | ||
| }) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.