forked from yusukebe/hono-remix-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: enable testing with Wrangler for Pages and Workers (yusukebe#28)
* test: enable testing with Wrangler for Pages and Workers * build before tests * add the test for vite in `examples/cloudflare-workers`
- Loading branch information
Showing
10 changed files
with
1,274 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 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 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,26 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
const port = 6173 | ||
|
||
export default defineConfig({ | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
use: { | ||
baseURL: `http://localhost:${port.toString()}`, | ||
}, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
timeout: 5000, | ||
retries: 2, | ||
}, | ||
], | ||
webServer: { | ||
command: `npm exec vite -- --port ${port.toString()} -c ./vite.config.ts`, | ||
port, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}) |
This file contains 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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
node_modules | ||
|
||
test-results | ||
|
||
/.cache | ||
/build | ||
.env | ||
.dev.vars | ||
|
||
.wrangler |
This file contains 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,27 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test('Should return 200 response - /', async ({ page }) => { | ||
const response = await page.goto('/') | ||
expect(response?.status()).toBe(200) | ||
|
||
const headers = response?.headers() ?? {} | ||
expect(headers['x-powered-by']).toBe('Remix and Hono') | ||
|
||
const contentH1 = await page.textContent('h1') | ||
expect(contentH1).toBe('Remix and Hono') | ||
|
||
const contentH2 = await page.textContent('h2') | ||
expect(contentH2).toBe('Var is My Value') | ||
|
||
const contentH3 = await page.textContent('h3') | ||
expect(contentH3).toBe('cf,ctx,caches are available') | ||
|
||
const contentH4 = await page.textContent('h4') | ||
expect(contentH4).toBe('Extra is stuff') | ||
}) | ||
|
||
test('Should return 200 response - /api', async ({ page }) => { | ||
const response = await page.goto('/api') | ||
expect(response?.status()).toBe(200) | ||
expect(await response?.json()).toEqual({ message: 'Hello', var: 'My Value' }) | ||
}) |
This file contains 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 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,26 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
const port = 6173 | ||
|
||
export default defineConfig({ | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
use: { | ||
baseURL: `http://localhost:${port.toString()}`, | ||
}, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
timeout: 5000, | ||
retries: 2, | ||
}, | ||
], | ||
webServer: { | ||
command: `npm exec vite -- --port ${port.toString()} -c ./vite.config.ts`, | ||
port, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}) |
This file contains 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,26 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
const port = 8797 | ||
|
||
export default defineConfig({ | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
use: { | ||
baseURL: `http://localhost:${port.toString()}`, | ||
}, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
timeout: 5000, | ||
retries: 2, | ||
}, | ||
], | ||
webServer: { | ||
command: `npm exec wrangler dev -- --port ${port.toString()} ./worker.ts`, | ||
port, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}) |
Oops, something went wrong.