Skip to content

test: Add E2E testing support#11221

Open
brophdawg11 wants to merge 14 commits intomainfrom
brophdawg11/testing-2-e2e
Open

test: Add E2E testing support#11221
brophdawg11 wants to merge 14 commits intomainfrom
brophdawg11/testing-2-e2e

Conversation

@brophdawg11
Copy link
Copy Markdown
Contributor

@brophdawg11 brophdawg11 commented Mar 31, 2026

Stacked on #11213

Adds support for E2E testing to remix/test.

*.test.e2e.tsx? files are identified as E2E test files in the test runner and receive a t.serve() method on the test context. This accepts a fetch handler, creates a server, and returns a fresh playwright page context:

describe('e2e', () => {
  it('tests my app', async (t) => {
    let router = createAppRouter();
    let page = await t.serve(router.fetch)

    await page.goto('/', { waitUntil: 'networkidle' })

    // Add an item to cart
    await page.locator('[data-test="add-to-cart"]').click()
    await page.waitForSelector('[data-test="remove-from-cart"]')

    // Navigate to cart and validate
    await page.locator('a[href="/cart"]').click()
    await page.waitForSelector('[data-test="shopping-cart"]')
    assert.equal(await page.locator('[data-test="quantity"]').innerText(), '1')
  })
})

New config options available in remix-test.config.ts:

  • browser.echo - echo browser console logs back to the server
  • browser.open - open the browser during testing (headless:false) and keep it open until you exit
  • glob.e2e - set glob that identifies an e2e test file (defaults to **/*.test.e2e.{ts,tsx})
  • playwrightConfig - a playwright config or a path to a one on disk
  • project - filter tests for a single playwright project

@github-actions
Copy link
Copy Markdown
Contributor

Preview Build Available

A preview build has been created for this PR. You can install it using:

pnpm install "remix-run/remix#preview/pr-11221&path:packages/remix"

This preview build will be updated automatically as you push new commits.

@brophdawg11 brophdawg11 marked this pull request as draft March 31, 2026 21:10
Comment thread demos/bookstore/app/app.test.e2e.ts Outdated
@brophdawg11 brophdawg11 force-pushed the brophdawg11/testing-2-e2e branch 3 times, most recently from c898d76 to 2448ec5 Compare April 1, 2026 15:58
navigationTimeout: 5_000,
actionTimeout: 5_000,
},
},
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Playwright configs can be inlined in remix-test.config.ts or you can just pass a string location of an existing playwright.config.ts file

Comment thread packages/test/src/lib/context.ts Outdated
page.setDefaultTimeout(options.playwrightPageOptions.actionTimeout)
}

let coverageEnabled = options.coverage && options.browser.browserType().name() === 'chromium'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only chromium supports coverage instrumentation

@brophdawg11 brophdawg11 force-pushed the brophdawg11/testing-2-e2e branch 4 times, most recently from 4e6311e to d290f51 Compare April 2, 2026 14:21
@brophdawg11 brophdawg11 force-pushed the brophdawg11/testing-2-e2e branch 5 times, most recently from ed7f21f to 7a7360f Compare April 2, 2026 19:59
Base automatically changed from brophdawg11/testing-1-assert-unit to main April 2, 2026 20:13
@brophdawg11 brophdawg11 force-pushed the brophdawg11/testing-2-e2e branch from 7a7360f to 1aaa16c Compare April 2, 2026 20:14
@brophdawg11 brophdawg11 marked this pull request as ready for review April 2, 2026 20:15
@brophdawg11 brophdawg11 requested a review from mjackson April 2, 2026 20:16
@brophdawg11 brophdawg11 force-pushed the brophdawg11/testing-2-e2e branch from da2f48b to 3bf8073 Compare April 8, 2026 15:54
@brophdawg11 brophdawg11 force-pushed the brophdawg11/testing-2-e2e branch from 3bf8073 to 2f6584f Compare April 8, 2026 15:56
"skipLibCheck": true,
"jsx": "react-jsx",
"jsxImportSource": "remix/component",
"preserveSymlinks": true
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mjackson We had to unset this option to get the playwright types to resolve properly. Do you recall why this was needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants