Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: recommend localhost over 127.0.0.1 (#34918)

Simon Knotta9bbf4b56d4b
diff --git a/docs/src/test-api/class-testconfig.md b/docs/src/test-api/class-testconfig.md
index 0acafa16c5..0d30f612ac 100644
--- a/docs/src/test-api/class-testconfig.md
+++ b/docs/src/test-api/class-testconfig.md
@@ -680,7 +680,7 @@ import { defineConfig } from '@playwright/test';
export default defineConfig({
webServer: {
command: 'npm run start',
- url: 'http://127.0.0.1:3000',
+ url: 'http://localhost:3000',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
},
@@ -709,19 +709,19 @@ export default defineConfig({
webServer: [
{
command: 'npm run start',
- url: 'http://127.0.0.1:3000',
+ url: 'http://localhost:3000',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
},
{
command: 'npm run backend',
- url: 'http://127.0.0.1:3333',
+ url: 'http://localhost:3333',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
}
],
use: {
- baseURL: 'http://127.0.0.1:3000',
+ baseURL: 'http://localhost:3000',
},
});
```
diff --git a/docs/src/test-configuration-js.md b/docs/src/test-configuration-js.md
index 822bd4ea0d..e3831c1911 100644
--- a/docs/src/test-configuration-js.md
+++ b/docs/src/test-configuration-js.md
@@ -35,7 +35,7 @@ export default defineConfig({
use: {
// Base URL to use in actions like `await page.goto('/')`.
- baseURL: 'http://127.0.0.1:3000',
+ baseURL: 'http://localhost:3000',
// Collect trace when retrying the failed test.
trace: 'on-first-retry',
@@ -50,7 +50,7 @@ export default defineConfig({
// Run your local dev server before starting the tests.
webServer: {
command: 'npm run start',
- url: 'http://127.0.0.1:3000',
+ url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
},
});
diff --git a/docs/src/test-use-options-js.md b/docs/src/test-use-options-js.md
index 6e1da0a228..12f97db46d 100644
--- a/docs/src/test-use-options-js.md
+++ b/docs/src/test-use-options-js.md
@@ -17,7 +17,7 @@ import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
// Base URL to use in actions like `await page.goto('/')`.
- baseURL: 'http://127.0.0.1:3000',
+ baseURL: 'http://localhost:3000',
// Populates context with given storage state.
storageState: 'state.json',
diff --git a/docs/src/test-webserver-js.md b/docs/src/test-webserver-js.md
index 985b487677..d4a7bbb19b 100644
--- a/docs/src/test-webserver-js.md
+++ b/docs/src/test-webserver-js.md
@@ -18,7 +18,7 @@ export default defineConfig({
// Run your local dev server before starting the tests
webServer: {
command: 'npm run start',
- url: 'http://127.0.0.1:3000',
+ url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
stdout: 'ignore',
stderr: 'pipe',
@@ -52,7 +52,7 @@ export default defineConfig({
// Run your local dev server before starting the tests
webServer: {
command: 'npm run start',
- url: 'http://127.0.0.1:3000',
+ url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
@@ -63,7 +63,7 @@ export default defineConfig({
It is also recommended to specify the `baseURL` in the `use: {}` section of your config, so that tests can use relative urls and you don't have to specify the full URL over and over again.
-When using [`method: Page.goto`], [`method: Page.route`], [`method: Page.waitForURL`], [`method: Page.waitForRequest`], or [`method: Page.waitForResponse`] it takes the base URL in consideration by using the [`URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor for building the corresponding URL. For Example, by setting the baseURL to `http://127.0.0.1:3000` and navigating to `/login` in your tests, Playwright will run the test using `http://127.0.0.1:3000/login`.
+When using [`method: Page.goto`], [`method: Page.route`], [`method: Page.waitForURL`], [`method: Page.waitForRequest`], or [`method: Page.waitForResponse`] it takes the base URL in consideration by using the [`URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor for building the corresponding URL. For Example, by setting the baseURL to `http://localhost:3000` and navigating to `/login` in your tests, Playwright will run the test using `http://localhost:3000/login`.
```js title="playwright.config.ts"
import { defineConfig } from '@playwright/test';
@@ -74,11 +74,11 @@ export default defineConfig({
// Run your local dev server before starting the tests
webServer: {
command: 'npm run start',
- url: 'http://127.0.0.1:3000',
+ url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
},
use: {
- baseURL: 'http://127.0.0.1:3000',
+ baseURL: 'http://localhost:3000',
},
});
```
@@ -89,7 +89,7 @@ Now you can use a relative path when navigating the page:
import { test } from '@playwright/test';
test('test', async ({ page }) => {
- // This will navigate to http://127.0.0.1:3000/login
+ // This will navigate to http://localhost:3000/login
await page.goto('./login');
});
```
@@ -106,19 +106,19 @@ export default defineConfig({
webServer: [
{
command: 'npm run start',
- url: 'http://127.0.0.1:3000',
+ url: 'http://localhost:3000',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
},
{
command: 'npm run backend',
- url: 'http://127.0.0.1:3333',
+ url: 'http://localhost:3333',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
}
],
use: {
- baseURL: 'http://127.0.0.1:3000',
+ baseURL: 'http://localhost:3000',
},
});
```
diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts
index 4c2766232d..e7cb99bf79 100644
--- a/packages/playwright/types/test.d.ts
+++ b/packages/playwright/types/test.d.ts
@@ -884,7 +884,7 @@ interface TestConfig<TestArgs = {}, WorkerArgs = {}> {
* export default defineConfig({
* webServer: {
* command: 'npm run start',
- * url: 'http://127.0.0.1:3000',
+ * url: 'http://localhost:3000',
* timeout: 120 * 1000,
* reuseExistingServer: !process.env.CI,
* },
@@ -915,19 +915,19 @@ interface TestConfig<TestArgs = {}, WorkerArgs = {}> {
* webServer: [
* {
* command: 'npm run start',
- * url: 'http://127.0.0.1:3000',
+ * url: 'http://localhost:3000',
* timeout: 120 * 1000,
* reuseExistingServer: !process.env.CI,
* },
* {
* command: 'npm run backend',
- * url: 'http://127.0.0.1:3333',
+ * url: 'http://localhost:3333',
* timeout: 120 * 1000,
* reuseExistingServer: !process.env.CI,
* }
* ],
* use: {
- * baseURL: 'http://127.0.0.1:3000',
+ * baseURL: 'http://localhost:3000',
* },
* });
* ```