-
Notifications
You must be signed in to change notification settings - Fork 230
Add e2e test infrastructure with Playwright + node-pty #6899
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
4 commits
Select commit
Hold shift + click to select a range
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
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
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,19 @@ | ||
| # Required: Client ID of the primary test app (must be in the genghis account's org) | ||
| # CI secret: E2E_CLIENT_ID | ||
| SHOPIFY_FLAG_CLIENT_ID= | ||
|
|
||
| # Required: Genghis account email for browser-based OAuth login | ||
| # CI secret: E2E_ACCOUNT_EMAIL | ||
| E2E_ACCOUNT_EMAIL= | ||
|
|
||
| # Required: Genghis account password for browser-based OAuth login | ||
| # CI secret: E2E_ACCOUNT_PASSWORD | ||
| E2E_ACCOUNT_PASSWORD= | ||
|
|
||
| # Required: Dev store FQDN for dev server / deploy tests (e.g. my-store.myshopify.com) | ||
| # CI secret: E2E_STORE_FQDN | ||
| E2E_STORE_FQDN= | ||
|
|
||
| # Optional: Client ID of a secondary app for config link tests | ||
| # CI secret: E2E_SECONDARY_CLIENT_ID | ||
| E2E_SECONDARY_CLIENT_ID= | ||
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,6 @@ | ||
| node_modules/ | ||
| test-results/ | ||
| playwright-report/ | ||
| dist/ | ||
| .env | ||
| .env.local |
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,5 @@ | ||
| // Re-export strip-ansi as a named export for easier use. | ||
| // strip-ansi v7+ is ESM-only and exports a default function. | ||
| import stripAnsiModule from 'strip-ansi' | ||
|
|
||
| export const stripAnsi: (text: string) => string = stripAnsiModule |
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,39 @@ | ||
| { | ||
| "name": "@shopify/e2e", | ||
| "version": "0.1.0", | ||
| "packageManager": "pnpm@10.11.1", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "test": "nx run e2e:test", | ||
| "lint": "nx lint", | ||
| "lint:fix": "nx lint:fix", | ||
| "type-check": "nx type-check" | ||
| }, | ||
| "eslintConfig": { | ||
| "extends": [ | ||
| "../../.eslintrc.cjs" | ||
| ], | ||
| "rules": { | ||
| "no-console": "off", | ||
| "import/extensions": [ | ||
| "error", | ||
| "never", | ||
| { | ||
| "ignorePackages": true | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "devDependencies": { | ||
| "@playwright/test": "^1.50.0", | ||
| "@types/node": "18.19.70", | ||
| "execa": "^7.2.0", | ||
| "node-pty": "^1.0.0", | ||
| "strip-ansi": "^7.1.0", | ||
| "tempy": "^1.0.1" | ||
| }, | ||
| "engines": { | ||
| "node": ">=20.10.0" | ||
| } | ||
| } |
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,42 @@ | ||
| /* eslint-disable line-comment-position */ | ||
| /* eslint-disable no-restricted-imports */ | ||
| import {defineConfig} from '@playwright/test' | ||
| import * as fs from 'fs' | ||
| import * as path from 'path' | ||
| import {fileURLToPath} from 'url' | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
|
||
| // Load .env file if present (CI provides env vars directly) | ||
| const envPath = path.join(__dirname, '.env') | ||
| if (fs.existsSync(envPath)) { | ||
| for (const line of fs.readFileSync(envPath, 'utf-8').split('\n')) { | ||
| const trimmed = line.trim() | ||
| if (!trimmed || trimmed.startsWith('#')) continue | ||
| const eqIdx = trimmed.indexOf('=') | ||
| if (eqIdx === -1) continue | ||
| const key = trimmed.slice(0, eqIdx).trim() | ||
| const value = trimmed.slice(eqIdx + 1).trim() | ||
| process.env[key] ??= value | ||
| } | ||
ryancbahan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| const isCI = Boolean(process.env.CI) | ||
|
|
||
| export default defineConfig({ | ||
| testDir: './tests', | ||
| fullyParallel: false, | ||
| forbidOnly: isCI, | ||
| retries: 0, | ||
| workers: 1, | ||
| maxFailures: isCI ? 3 : 0, // Stop early in CI after 3 failures | ||
| reporter: isCI ? [['html', {open: 'never'}], ['list']] : [['list']], | ||
| timeout: 3 * 60 * 1000, // 3 minutes per test | ||
| globalTimeout: 15 * 60 * 1000, // 15 minutes total | ||
|
|
||
| use: { | ||
| trace: isCI ? 'on' : 'off', | ||
| screenshot: isCI ? 'on' : 'off', | ||
| video: 'off', | ||
| }, | ||
| }) | ||
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,39 @@ | ||
| { | ||
| "name": "e2e", | ||
| "$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
| "sourceRoot": "packages/e2e", | ||
| "projectType": "library", | ||
| "implicitDependencies": ["cli", "create-app"], | ||
| "tags": ["scope:e2e"], | ||
| "targets": { | ||
| "test": { | ||
| "executor": "nx:run-commands", | ||
| "dependsOn": ["^build"], | ||
| "options": { | ||
| "command": "pnpm playwright test", | ||
| "cwd": "packages/e2e" | ||
| } | ||
| }, | ||
| "lint": { | ||
| "executor": "nx:run-commands", | ||
| "options": { | ||
| "command": "pnpm eslint \"**/*.ts\"", | ||
| "cwd": "packages/e2e" | ||
| } | ||
| }, | ||
| "lint:fix": { | ||
| "executor": "nx:run-commands", | ||
| "options": { | ||
| "command": "pnpm eslint '**/*.ts' --fix", | ||
| "cwd": "packages/e2e" | ||
| } | ||
| }, | ||
| "type-check": { | ||
| "executor": "nx:run-commands", | ||
| "options": { | ||
| "command": "pnpm tsc --noEmit", | ||
| "cwd": "packages/e2e" | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For initial E2E tests, we won't create new apps but instead use existing ones. We should 100% evolve this, but we need a starting point to monitor and observe stability of this job.