<@U04UQ68083H> what is the recommended way to test...
# ory-copilot
c
@chilly-king-10285 what is the recommended way to test e2e application which uses managed ORY Network authenthication?
b
A message from kapa.ai
The recommended way to test end-to-end (E2E) applications that use managed Ory Network authentication is to use browser automation tools (such as Playwright or Cypress) to interact with your application through the Ory Tunnel. The Ory Tunnel exposes Ory Network APIs on your local domain (e.g., localhost), which is necessary for session cookies and authentication flows to work correctly during local development and testing. Key steps: 1. Start your application locally (e.g., on http://localhost:3000). 2. Start the Ory Tunnel to proxy Ory Network APIs to your local domain:
Copy code
ory tunnel --dev --project <PROJECT_SLUG> <http://localhost:3000>
This will expose your app at http://localhost:4000, where authentication flows will work as expected for E2E tests. 3. Run your E2E tests against http://localhost:4000 using your preferred tool (e.g., Cypress, Playwright). This simulates real user interactions, including registration, login, and session management. Ory provides example E2E test setups for various frameworks and UI libraries, such as Playwright-based tests for Ory Elements, and Cypress tests for React Native and Node.js reference implementations. You can reference these examples to structure your own tests: - For custom UIs with Ory Elements, use the
@ory/elements-test
library and Playwright ([details here](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-ory-elements#end-to-end-tests)). - For React Native or Node.js, see the [Cypress E2E test setup](https://www.ory.sh/docs/kratos/guides/e2e-integration-tests). Important notes: - Always run your tests against the Ory Tunnel endpoint (http://localhost:4000), not directly against the Ory Network API URL. - For local development, ensure all requests use the same domain (localhost) to avoid cookie issues. - For advanced scenarios (e.g., TOTP, WebAuthn), Ory provides example E2E tests you can reference for your own test suites. References: [Local development and Ory Tunnel](https://www.ory.sh/docs/getting-started/local-development#local-development) [Custom UI E2E tests](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-ory-elements#end-to-end-tests) [Integration test guides](https://www.ory.sh/docs/kratos/guides/e2e-integration-tests)