Skip to content

Commit

Permalink
test: react script within nextjs (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley authored Feb 2, 2022
1 parent 1e95fa5 commit 1304535
Show file tree
Hide file tree
Showing 14 changed files with 720 additions and 17 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on: [push, pull_request]
jobs:
test-chromium:
name: Test Chromium (Ubuntu)
strategy:
fail-fast: false

runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -51,9 +48,6 @@ jobs:

test-webkit:
name: Test WebKit (MacOS)
strategy:
fail-fast: false

runs-on: macos-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -92,9 +86,6 @@ jobs:

benchmark-chromium:
name: Benchmark Chromium (Ubuntu)
strategy:
fail-fast: false

runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.cache/
.next/
.DS_Store
node_modules/
/integration/
/lib/
/react/
/tests/~partytown/
/tests/nextjs/public/
/tests/benchmarks/screenshots/
/tests/videos/
/tsc/
Expand Down
16 changes: 10 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
"test.atomics": "playwright test tests/integrations tests/platform --config playwright.atomics.config.ts --browser=chromium",
"test.chromium": "playwright test tests/integrations tests/platform --browser=chromium",
"test.webkit": "playwright test tests/integrations tests/platform --browser=webkit",
"test.nextjs.chromium": "cd tests/nextjs && npm i && playwright test --config playwright.nextjs.ts --browser=chromium",
"test.nextjs.webkit": "cd tests/nextjs && npm i && playwright test --config playwright.nextjs.ts --browser=webkit",
"benchmark": "node tests/benchmarks/run.cjs",
"test.unit": "uvu -r tsm tests/unit",
"tsc.watch": "tsc -w",
Expand Down
2 changes: 0 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const config: PlaywrightTestConfig = {
dir: 'tests/videos/',
},
},
geolocation: { latitude: 33.993553, longitude: -117.928116 },
permissions: ['geolocation'],
},
webServer: {
command: 'npm run serve.test',
Expand Down
2 changes: 2 additions & 0 deletions src/lib/main/snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export function snippet(
// no support for atomics or service worker
fallback();
}
} else if (debug && scripts!.length === 0) {
console.debug('No Partytown scripts found');
}
} else if (debug) {
console.warn('Partytown config.lib url must start with "/"');
Expand Down
5 changes: 5 additions & 0 deletions tests/nextjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```bash
npm run dev
```

[http://localhost:3000](http://localhost:3000)
3 changes: 3 additions & 0 deletions tests/nextjs/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
reactStrictMode: true,
};
16 changes: 16 additions & 0 deletions tests/nextjs/nextjs.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { test, expect } from '@playwright/test';

test('nextjs', async ({ page }) => {
await page.goto('/');

await page.waitForSelector('.completed');

const h1 = page.locator('h1');
await expect(h1).toHaveText('Next.js with 🎉');

const outputNextScript = page.locator('#output-next-script');
await expect(outputNextScript).toHaveText('passed');

const outputScript = page.locator('#output-script');
await expect(outputScript).toHaveText('passed');
});
Loading

1 comment on commit 1304535

@vercel
Copy link

@vercel vercel bot commented on 1304535 Feb 2, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.