Skip to content

Skip remote E2E tests when no auth available #9826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 3, 2025
Merged

Conversation

penalosa
Copy link
Contributor

@penalosa penalosa commented Jul 2, 2025

A large number of Wrangler's "E2E" tests actually require no Cloudflare auth tokens. This PR changes our E2E setup to enable running pnpm test:e2e:wrangler with no other arguments, which will run all non-API-requiring E2E tests, including on forks in CI.

Additionally, you can pass arguments to pnpm test:e2e:wrangler in order to configure Vitest. e.g. pnpm test:e2e:wrangler -u to update snapshots.


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal repo change
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: not a Wrangler change

@penalosa penalosa requested a review from a team as a code owner July 2, 2025 16:11
Copy link

changeset-bot bot commented Jul 2, 2025

⚠️ No Changeset found

Latest commit: 68f2a0c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

pkg-pr-new bot commented Jul 2, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@9826

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@9826

miniflare

npm i https://pkg.pr.new/miniflare@9826

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@9826

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@9826

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@9826

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@9826

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@9826

wrangler

npm i https://pkg.pr.new/wrangler@9826

commit: 68f2a0c

Comment on lines -62 to -64
WRANGLER: node --no-warnings ${{ github.workspace}}/packages/wrangler/bin/wrangler.js
WRANGLER_IMPORT: ${{ github.workspace}}/packages/wrangler/wrangler-dist/cli.js
MINIFLARE_IMPORT: ${{ github.workspace}}/packages/miniflare/dist/src/index.js
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See tools/e2e/runIndividualE2EFiles.ts for this

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

A few nits but nice QOL improvement

Comment on lines +63 to +75

// If the user hasn't specifically set an inspector port, set it to 0 to reduce port conflicts
const inspectorPort =
command.includes(`--inspector-port`) || !command.startsWith("wrangler dev")
? ""
: " --inspector-port 0";

// If the user hasn't specifically set a Worker port, set it to 0 to reduce port conflicts
const workerPort =
command.includes(`--port`) || !command.startsWith("wrangler dev")
? ""
: " --port 0";
return `${WRANGLER} ${command.slice("wrangler ".length)}${inspectorPort}${workerPort}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

Comment on lines 835 to 848
CLOUDFLARE_ACCOUNT_ID
? [
{ imagesMode: "remote", extraFlags: "" },
{
imagesMode: "local",
extraFlags: "--experimental-images-local-mode",
},
]
: [
{
imagesMode: "local",
extraFlags: "--experimental-images-local-mode",
},
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
CLOUDFLARE_ACCOUNT_ID
? [
{ imagesMode: "remote", extraFlags: "" },
{
imagesMode: "local",
extraFlags: "--experimental-images-local-mode",
},
]
: [
{
imagesMode: "local",
extraFlags: "--experimental-images-local-mode",
},
]
[
... (CLOUDFLARE_ACCOUNT_ID ? [{ imagesMode: "remote", extraFlags: "" }] : []),
{
imagesMode: "local",
extraFlags: "--experimental-images-local-mode",
},
]

Comment on lines 27 to 31
describe.each(
CLOUDFLARE_ACCOUNT_ID
? [{ cmd: "wrangler dev" }, { cmd: "wrangler dev --remote" }]
: [{ cmd: "wrangler dev" }]
)("basic js dev: $cmd", ({ cmd }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
describe.each(
CLOUDFLARE_ACCOUNT_ID
? [{ cmd: "wrangler dev" }, { cmd: "wrangler dev --remote" }]
: [{ cmd: "wrangler dev" }]
)("basic js dev: $cmd", ({ cmd }) => {
describe.each([
... (CLOUDFLARE_ACCOUNT_ID ? [{ cmd: "wrangler dev --remote" }] : []),
{ cmd: "wrangler dev" }
])("basic js dev: $cmd", ({ cmd }) => {

Comment on lines 7 to 12
const RUNTIMES = CLOUDFLARE_ACCOUNT_ID
? [
{ flags: "--remote", runtime: "remote" },
{ flags: "", runtime: "local" },
]
: [{ flags: "", runtime: "local" }];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const RUNTIMES = CLOUDFLARE_ACCOUNT_ID
? [
{ flags: "--remote", runtime: "remote" },
{ flags: "", runtime: "local" },
]
: [{ flags: "", runtime: "local" }];
const RUNTIMES = [
...(CLOUDFLARE_ACCOUNT_ID ? [{ flags: "--remote", runtime: "remote" }] : []),
{ flags: "", runtime: "local" },
]

Comment on lines 14 to 16
const OPTIONS = CLOUDFLARE_ACCOUNT_ID
? [{ remote: false }, { remote: true }]
: [{ remote: false }];
Copy link
Contributor

Choose a reason for hiding this comment

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

etc

Comment on lines +43 to +45
process.env.WRANGLER ??= `node --no-warnings ${process.cwd()}/packages/wrangler/bin/wrangler.js`;
process.env.WRANGLER_IMPORT ??= `${process.cwd()}/packages/wrangler/wrangler-dist/cli.js`;
process.env.MINIFLARE_IMPORT ??= `${process.cwd()}/packages/miniflare/dist/src/index.js`;
Copy link
Contributor

Choose a reason for hiding this comment

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

To be honest I think we should probably just hard code these into the tests now.
We only had them before because we sometimes tested against beta or production versions of Wrangler, which we don't do now.
In a follow up...

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Jul 3, 2025
@penalosa penalosa enabled auto-merge July 3, 2025 13:54
Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Let's hope no one just provides a CLOUDFLARE_ACCOUNT_ID and not a CLOUDFLARE_API_TOKEN.

@penalosa penalosa added this pull request to the merge queue Jul 3, 2025
Merged via the queue into main with commit 57d3d01 Jul 3, 2025
35 of 36 checks passed
@penalosa penalosa deleted the penalosa/local-e2e branch July 3, 2025 16:27
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants