Skip to content

Commit 798997b

Browse files
committed
Add local proxying docs
1 parent 4df6dc8 commit 798997b

7 files changed

Lines changed: 153 additions & 15 deletions

File tree

75.6 KB
Loading

src/content/docs/explanation/transfer-state-to-remote-runners.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@ Endform has two additional ways of transferring state to the remote runners:
6161
- **Files** - `additionalFiles` in your `endform.jsonc` config
6262

6363
For more information on these options, see the [endform config reference](/docs/reference/endform-config).
64+
65+
## Transfering network traffic from the remote runners
66+
67+
To find out more about how to direct traffic from the remote runners to your local network, see the [proxy traffic via your local network](/docs/guides/proxy-via-local) guide.

src/content/docs/guides/getting-started.mdx

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,51 @@ title: Getting Started
33
description: Running your tests with Endform for the first time.
44
---
55

6-
import { Aside } from '@astrojs/starlight/components';
6+
import { Aside, Tabs, TabItem } from '@astrojs/starlight/components';
77

88
Make sure to check out the [requirements](/docs/reference/requirements) before you start.
99

1010
# Getting Started
1111

1212
The easiest way to get started with endform, and to check if your setup is compatible with endform at the moment, is to run the endform cli from your playwright project directory.
1313

14-
```
14+
```sh
1515
npx endform@latest test
1616
```
1717

1818
This will prompt you to login and run your tests.
1919

20-
<Aside>
2120

22-
Since endform is currently in beta, we recommend _not_ pinning the version of endform in your `package.json`, and instead "always running latest" by running `npx endform@latest test`.
21+
# Install the `endform` CLI
22+
23+
<Tabs syncKey="pkg">
24+
<TabItem label="npm">
25+
```sh
26+
npm install endform
27+
```
28+
</TabItem>
29+
<TabItem label="pnpm">
30+
```sh
31+
pnpm install endform
32+
```
33+
</TabItem>
34+
<TabItem label="Yarn">
35+
```sh
36+
yarn install endform
37+
```
38+
</TabItem>
39+
<TabItem label="Bun">
40+
```sh
41+
bun install endform
42+
```
43+
</TabItem>
44+
</Tabs>
2345

46+
<Aside>
47+
Since endform is currently in beta, we reccomend a very high update cadence of the CLI. Please try to keep within the _last 2 weeks_ of releases.
2448
</Aside>
2549

50+
2651
# Running your tests in CI
2752

2853
Once you have your tests passing with endform from your machine, you might want to run endform in your CI pipeline.
@@ -33,7 +58,7 @@ The easiest way to do this is to replace your "playwright test" command with "en
3358

3459
Here's an example of a what a GitHub Actions workflow might look like:
3560

36-
```
61+
```yml
3762
name: Run Playwright tests with Endform
3863
on:
3964
push:
@@ -54,7 +79,7 @@ jobs:
5479
run: npm install
5580

5681
- name: Run tests with Endform
57-
run: npx endform@latest test
82+
run: npx endform@latest test # or npm run endform test
5883
env:
5984
ENDFORM_API_KEY: ${{ secrets.ENDFORM_API_KEY }}
6085
```
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
title: Proxy traffic via your local network
3+
description: How to proxy traffic from your remote runners to your local network. This helps to run tests against local servers.
4+
---
5+
6+
import { Steps, Tabs, TabItem, Code, Aside } from '@astrojs/starlight/components';
7+
8+
import { Image } from "astro:assets";
9+
import LocalTraffic from "../../../assets/local-server-traffic.png";
10+
11+
Servers that you want to test against that are either running locally or within a private network are not automatically exposed to the internet.
12+
These servers are not reachable by default from the remotely running Playwright instances.
13+
Trying to reach them without this extra setup, would likely result in connection errors in your tests.
14+
15+
16+
When this happens, we need a method of shuttling traffic between the remote runners and the servers running on your local network.
17+
18+
<Image
19+
src={LocalTraffic}
20+
alt="A diagram of the traffic from the remote runners through your CLI to your local server."
21+
height={500}
22+
/>
23+
24+
Endform has the ability to connect the remote Playwright runners to the servers on your local network via direct, hole-punched, encrypted, peer-to-peer connections.
25+
We can do this by utilizing the [iroh network](https://www.iroh.computer/docs/overview).
26+
27+
## Setting up endform to proxy traffic
28+
29+
<Aside>
30+
Proxying traffic via your local network is currently in alpha, we would be grateful for any feedback you have on this feature.
31+
</Aside>
32+
33+
34+
<Steps>
35+
36+
1. ### Install the addon package
37+
38+
In order for traffic to be proxied, we need to install the extra `endform-proxy-network` package in the same place as you installed the main `endform` CLI.
39+
40+
<Tabs syncKey="pkg">
41+
<TabItem label="npm">
42+
```sh
43+
npm install endform-proxy-network
44+
```
45+
</TabItem>
46+
<TabItem label="pnpm">
47+
```sh
48+
pnpm install endform-proxy-network
49+
```
50+
</TabItem>
51+
<TabItem label="Yarn">
52+
```sh
53+
yarn install endform-proxy-network
54+
```
55+
</TabItem>
56+
<TabItem label="Bun">
57+
```sh
58+
bun install endform-proxy-network
59+
```
60+
</TabItem>
61+
</Tabs>
62+
63+
2. ### Configure which traffic to proxy.
64+
65+
#### As a playwright `webServer`
66+
If you want to run your local server as a [playwright `webServer`](https://playwright.dev/docs/api/class-testconfig#test-config-web-server)
67+
then you're done! Leave your web server configuration as is, and we will automatically proxy the traffic to your local server.
68+
69+
#### With your own custom server
70+
If you're running a server outside of playwright - that's fine. You can tell endform which traffic to proxy by using a `endform.jsonc` file.
71+
72+
<Code language="json" title="endform.jsonc" code={`
73+
{
74+
"proxyNetworkHosts": [
75+
"<loopback>",
76+
"*.my-special-domain.com"
77+
]
78+
}
79+
`} />
80+
81+
You can read more about the `proxyNetworkHosts` configuration in the [endform config reference](/docs/reference/endform-config#proxy-network-hosts).
82+
83+
3. ### Run your tests!
84+
85+
That's it! You can now run your tests as normal, and the traffic will be proxied via the cli to your target server.
86+
87+
88+
89+
90+
91+
92+
</Steps>

src/content/docs/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Endform is:
1212
- A very fast _remote_ test runner for your playwright end-to-end tests.
1313
- (Soon) A dashboard for viewing and analyzing your test results.
1414

15-
Endform is currently in early beta. If you're here, it's probably because we've given you early access,
15+
Endform is currently in beta. If you're here, it's probably because we've given you early access,
1616
and we appreciate you taking the time to try it out.
1717

1818
## Guides

src/content/docs/reference/endform-config.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Currently, `endform.jsonc` supports the following options:
1818

1919
`additionalFiles`: an array of strings used as globs to send extra files to your test machines.
2020

21-
```
21+
```json
2222
{
2323
"additionalFiles": ["user-state/*"]
2424
}
@@ -31,7 +31,7 @@ However if your tests have implicit dependencies on more files, use this paramet
3131

3232
`environmentVariables`: an array of string regular expressions that are used to match environment variables that should be transferred to the remote runners.
3333

34-
```
34+
```json
3535
{
3636
"environmentVariables": ["VERCEL_.*"]
3737
}
@@ -41,3 +41,20 @@ By default the following environment variables are automatically transferred:
4141

4242
- Environment variables that start with `E2E_`
4343
- All environment variables that are set in your `playwright.config.ts`
44+
45+
### `proxyNetworkHosts`
46+
47+
Choose which host names will have their traffic redirected to the CLI from the remote runners.
48+
All the traffic sent from the remote runners to your CLI is sent encrypted over direct peer-to-peer connections. Read more about [traffic to local servers here](/docs/guides/proxy-via-local).
49+
50+
```json
51+
{
52+
"proxyNetworkHosts": ["*.test.internal-domain", "*.staging.internal-domain", "<loopback>"]
53+
}
54+
```
55+
56+
Each string in the array is a match rule. Either:
57+
58+
- A hostname pattern `my-domain.com`, `*.interal.org`
59+
- An IP literal like `127.0.0.1`
60+
- `<loopback>` to match interfaces `localhost`, `*.localhost`, `127.0.0.1`, `[::1]`

src/content/docs/reference/requirements.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ If you keep your tests decoupled from your application already by, for example,
1616

1717
### Remote
1818

19-
Since your tests will be running on remote machines, your test environment needs to be accessible on the public internet.
20-
Endform does not support servers running "locally" / on `localhost`.
19+
Since your tests will be running on remote machines, the servers you are testing against need to be accesible to the remote runners.
20+
There are two ways to acheive this:
2121

22-
We reccomend using playwright directly when creating tests / running against `localhost`, and to run endform in your ci environment / against your test/stage/preview environments.
22+
- You are running preview infrastructure or a testing environment that is exposed to the internet anyway.
23+
- You can use the `endform-proxy-network` addon to shuttle traffic between the remote runners and the machine your CLI runs on. Check out the [guide on proxying traffic via your local network](/docs/guides/proxy-via-local) for more information about this approach.
2324

2425
## Playwright Requirements
2526

2627
- We support playwright projects written in typescript and javascript.
2728
- The length of an individual test run is limited to 4 minutes (same as the `testConfig.timeout` option). The playwright default timeout is 30 seconds. This does not include retries.
2829
- We currently only support the latest minor version of playwright (`1.53.0` at the time of writing).
29-
- We currently only support Chrome. We run the same version of Chrome as the playwright version you are running ships with.
30+
- We currently only support Chrome. We run the same version of Chrome as the playwright version you are running ships with. Let us know if you are in need of more browsers and we can prioritise this.
3031

3132
### Playwright Configuration Options
3233

@@ -42,8 +43,7 @@ Options that we currently don't support, but will do in the future (let us know
4243

4344
Options that aren't supported since they don't make sense in a remote context:
4445

45-
- `webWorkers`
46-
- `fullyParallel` is always `true`
46+
- `fullyParallel` is always `true`, but you can limit concurrency using settings in the endform dashboard.
4747

4848
## Node Requirements
4949

0 commit comments

Comments
 (0)