-
Notifications
You must be signed in to change notification settings - Fork 0
tests? #2
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
tests? #2
Changes from 8 commits
c3b559e
127bb55
b81fa50
58751c4
07ad649
b1a9528
12c434c
cf14d09
b6f59a2
d657c22
16c3475
4902048
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: Next.js App Router - PostHog Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| test: | ||
| timeout-minutes: 60 | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: lts/* | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: latest | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| cd basics/next-app-router | ||
| pnpm install | ||
| - name: Install Playwright Browsers | ||
| run: | | ||
| cd basics/next-app-router | ||
| pnpm exec playwright install chromium --with-deps | ||
| - name: Run Playwright tests | ||
| run: | | ||
| cd basics/next-app-router | ||
| pnpm exec playwright test | ||
| env: | ||
| NEXT_PUBLIC_POSTHOG_KEY: ${{ vars.NEXT_PUBLIC_POSTHOG_KEY }} | ||
| NEXT_PUBLIC_POSTHOG_HOST: ${{ vars.NEXT_PUBLIC_POSTHOG_HOST }} | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: playwright-report | ||
| path: basics/next-app-router/playwright-report/ | ||
| retention-days: 30 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # PostHog Configuration | ||
| # Get your PostHog API key from: https://app.posthog.com/project/settings | ||
| NEXT_PUBLIC_POSTHOG_KEY=your_posthog_project_api_key_here | ||
| # NEXT_PUBLIC_POSTHOG_HOST=https://eu.i.posthog.com | ||
| NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,10 @@ | |
|
|
||
| # testing | ||
| /coverage | ||
| /test-results/ | ||
| /playwright-report/ | ||
| /blob-report/ | ||
| /playwright/.cache/ | ||
|
|
||
| # next.js | ||
| /.next/ | ||
|
|
@@ -31,7 +35,7 @@ yarn-error.log* | |
| .pnpm-debug.log* | ||
|
|
||
| # env files (can opt-in for committing if needed) | ||
| .env* | ||
| .env | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| # vercel | ||
| .vercel | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,4 +9,9 @@ posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, { | |
| capture_exceptions: true, | ||
| // Turn on debug in development mode | ||
| debug: process.env.NODE_ENV === "development", | ||
| // @ignoreBlockStart | ||
| // Disable request batching in test environment | ||
| request_batching: false, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is really suspect. I plan on updating this to detect if we're in CI and disable batching + allow bot agents with environment variables.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One wrinkle here is that we want to keep this kind of artifact ( could we do some sort of rewrite of it only during testing, or alter PostHog's behavior through a property set at runtime during tests?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh derp I imagine that's what you mean by your remarks about environment variables, carry on! |
||
| opt_out_useragent_filter: true, // This disables bot detection | ||
| // @ignoreBlockEnd | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // @ignoreFile | ||
| import { defineConfig, devices } from '@playwright/test'; | ||
| import { config } from 'dotenv'; | ||
|
|
||
| // Load environment variables from .env file | ||
| config(); | ||
|
|
||
| /** | ||
| * See https://playwright.dev/docs/test-configuration. | ||
| */ | ||
| export default defineConfig({ | ||
| testDir: './tests', | ||
| /* 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: { | ||
| /* Base URL to use in actions like `await page.goto('/')`. */ | ||
| baseURL: 'http://127.0.0.1:3333', | ||
|
|
||
| /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
| trace: 'on-first-retry', | ||
| }, | ||
|
|
||
| /* Global timeout settings */ | ||
| timeout: 180000, // 3 minutes for individual tests | ||
| expect: { | ||
| timeout: 60000, // 1 minute for expect assertions | ||
| }, | ||
|
|
||
| /* Configure projects for major browsers */ | ||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { ...devices['Desktop Chrome'] }, | ||
| snapshotPathTemplate: '{testDir}/{testFileName}-snapshots/{arg}{ext}', | ||
| }, | ||
| ], | ||
|
|
||
| /* Run your local dev server before starting the tests */ | ||
| webServer: { | ||
| command: 'pnpm dev --port 3333', | ||
| url: 'http://127.0.0.1:3333', | ||
| reuseExistingServer: false, // Always start fresh | ||
| }, | ||
| }); | ||
|
|
||
|
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.