Skip to content

Commit 08b2dfc

Browse files
authored
test(remix): Add basic test for remix E2E app (#8633)
This adds a super basic remix test scenario that handles booting the server & closing it again properly, ensuring tests don't hang but verify that remix boots up as expected.
1 parent 9cf76d8 commit 08b2dfc

File tree

4 files changed

+79
-3
lines changed

4 files changed

+79
-3
lines changed

packages/e2e-tests/test-applications/create-next-app/tests/behaviour-client.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const sentryTestProject = process.env.E2E_TEST_SENTRY_TEST_PROJECT;
77
const EVENT_POLLING_TIMEOUT = 30_000;
88

99
test('Sends a client-side exception to Sentry', async ({ page }) => {
10-
page.on('console', msg => console.log(msg.text()));
1110
await page.goto('/');
1211

1312
const exceptionButton = page.locator('id=exception-button');

packages/e2e-tests/test-applications/create-remix-app/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"dev": "remix dev",
77
"start": "remix-serve build",
88
"typecheck": "tsc",
9-
"test:build": "pnpm install && pnpm build",
10-
"test:assert": "pnpm -v"
9+
"test:build": "pnpm install && npx playwright install && pnpm build",
10+
"test:assert": "pnpm playwright test"
1111
},
1212
"dependencies": {
1313
"@sentry/remix": "latest || *",
@@ -20,6 +20,7 @@
2020
"react-dom": "^18.2.0"
2121
},
2222
"devDependencies": {
23+
"@playwright/test": "^1.36.2",
2324
"@remix-run/dev": "^1.16.1",
2425
"@remix-run/eslint-config": "^1.16.1",
2526
"@types/react": "^18.0.35",
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import type { PlaywrightTestConfig } from '@playwright/test';
2+
import { devices } from '@playwright/test';
3+
4+
const port = 3030;
5+
6+
/**
7+
* See https://playwright.dev/docs/test-configuration.
8+
*/
9+
const config: PlaywrightTestConfig = {
10+
testDir: './tests',
11+
/* Maximum time one test can run for. */
12+
timeout: 60 * 1000,
13+
expect: {
14+
/**
15+
* Maximum time expect() should wait for the condition to be met.
16+
* For example in `await expect(locator).toHaveText();`
17+
*/
18+
timeout: 5000,
19+
},
20+
/* Run tests in files in parallel */
21+
fullyParallel: true,
22+
/* Fail the build on CI if you accidentally left test.only in the source code. */
23+
forbidOnly: !!process.env.CI,
24+
/* Retry on CI only */
25+
retries: 0,
26+
/* Opt out of parallel tests on CI. */
27+
workers: 1,
28+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
29+
reporter: 'list',
30+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
31+
use: {
32+
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
33+
actionTimeout: 0,
34+
35+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
36+
trace: 'on-first-retry',
37+
},
38+
39+
/* Configure projects for major browsers */
40+
projects: [
41+
{
42+
name: 'chromium',
43+
use: {
44+
...devices['Desktop Chrome'],
45+
},
46+
},
47+
// For now we only test Chrome!
48+
// {
49+
// name: 'firefox',
50+
// use: {
51+
// ...devices['Desktop Firefox'],
52+
// },
53+
// },
54+
// {
55+
// name: 'webkit',
56+
// use: {
57+
// ...devices['Desktop Safari'],
58+
// },
59+
// },
60+
],
61+
62+
/* Run your local dev server before starting the tests */
63+
webServer: {
64+
command: `PORT=${port} pnpm start`,
65+
port,
66+
},
67+
};
68+
69+
export default config;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('Boots up correctly', async ({ page }) => {
4+
await page.goto('/');
5+
6+
await expect(page.getByRole('heading')).toHaveText('Welcome to Remix');
7+
});

0 commit comments

Comments
 (0)