Skip to content

Commit 99b68c3

Browse files
authored
chore: move smoke tests to vitest (#315)
* chore: move playwright specific utils to separate module * chore: move smoke tests to vitest * chore: cleanup html response from comments, don't copy .yarn * test: add netlify token to vitest tests * test: only distribute not skipped tests
1 parent c5b0ad2 commit 99b68c3

22 files changed

+133
-127
lines changed

.github/workflows/run-tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ jobs:
8686
id: fixture-cache-key
8787
# Fixtures only need to be rebuilt if anything in the tests/fixtures directory changes,
8888
# so we're using a hash of the files in that directory as the cache key.
89-
run: echo "key=$(git ls-files -s tests/fixtures/ tests/prepare.mjs | git hash-object --stdin)" >> "$GITHUB_OUTPUT"
89+
run:
90+
echo "key=$(git ls-files -s tests/fixtures/ tests/prepare.mjs | git hash-object --stdin)"
91+
>> "$GITHUB_OUTPUT"
9092
shell: bash
9193
- name: Cache Fixtures
9294
id: cache-fixtures
@@ -99,3 +101,5 @@ jobs:
99101
run: npm run pretest
100102
- name: 'Test'
101103
run: npm run test:ci -- --shard=${{ matrix.shard }}
104+
env:
105+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_TOKEN }}

tests/e2e/edge-middleware.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@playwright/test'
2-
import { test } from '../utils/create-e2e-fixture.js'
2+
import { test } from '../utils/playwright-helpers.js'
33
import { getImageSize } from 'next/dist/server/image-optimizer.js'
44

55
test('Runs edge middleware', async ({ page, middleware }) => {

tests/e2e/nx-integrated.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, type Locator } from '@playwright/test'
2-
import { test } from '../utils/create-e2e-fixture.js'
2+
import { test } from '../utils/playwright-helpers.js'
33

44
const expectImageWasLoaded = async (locator: Locator) => {
55
expect(await locator.evaluate((img: HTMLImageElement) => img.naturalHeight)).toBeGreaterThan(0)

tests/e2e/on-demand-app.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@playwright/test'
2-
import { test } from '../utils/create-e2e-fixture.js'
2+
import { test } from '../utils/playwright-helpers.js'
33

44
test.describe('app router on-demand revalidation', () => {
55
test('revalidatePath', async ({ page, serverComponents }) => {

tests/e2e/package-manager.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@playwright/test'
2-
import { test } from '../utils/create-e2e-fixture.js'
2+
import { test } from '../utils/playwright-helpers.js'
33

44
// those tests have different fixtures and can run in parallel
55
test.describe.configure({ mode: 'parallel' })

tests/e2e/page-router.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@playwright/test'
2-
import { test } from '../utils/create-e2e-fixture.js'
2+
import { test } from '../utils/playwright-helpers.js'
33

44
export function waitFor(millis: number) {
55
return new Promise((resolve) => setTimeout(resolve, millis))

tests/e2e/simple-app.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Locator, expect } from '@playwright/test'
2-
import { test } from '../utils/create-e2e-fixture.js'
2+
import { test } from '../utils/playwright-helpers.js'
33

44
const expectImageWasLoaded = async (locator: Locator) => {
55
expect(await locator.evaluate((img: HTMLImageElement) => img.naturalHeight)).toBeGreaterThan(0)

tests/e2e/smoke.test.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/e2e/turborepo.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@playwright/test'
2-
import { test } from '../utils/create-e2e-fixture.js'
2+
import { test } from '../utils/playwright-helpers.js'
33

44
// those tests have different fixtures and can run in parallel
55
test.describe.configure({ mode: 'parallel' })

tests/smoke/deploy.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { expect, test } from 'vitest'
2+
import { Fixture, fixtureFactories } from '../utils/create-e2e-fixture'
3+
4+
async function smokeTest(createFixture: () => Promise<Fixture>) {
5+
const fixture = await createFixture()
6+
const response = await fetch(fixture.url)
7+
expect(response.status).toBe(200)
8+
9+
// remove comments that React injects into produced html
10+
const body = (await response.text()).replace(/<!--.+-->/g, '')
11+
await expect(body).toContain('SSR: yes')
12+
}
13+
14+
test('yarn@3 monorepo with pnpm linker', async () => {
15+
await smokeTest(fixtureFactories.yarnMonorepoWithPnpmLinker)
16+
})

0 commit comments

Comments
 (0)