Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 31 additions & 36 deletions packages/vite-plugin-cloudflare/e2e/remote-bindings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ import {
} from "./helpers.js";

const commands = ["dev", "buildAndPreview"] as const;

if (!process.env.CLOUDFLARE_ACCOUNT_ID || !process.env.CLOUDFLARE_API_TOKEN) {
const isWindows = process.platform === "win32";

// Remote bindings tests are skipped on Windows due to slow/unreliable remote proxy
// session initialization times in CI, which causes intermittent timeout failures.
// See: https://jira.cfdata.org/browse/DEVX-2030
if (isWindows) {
describe.skip("Skipping remote bindings tests on Windows.");
} else if (
!process.env.CLOUDFLARE_ACCOUNT_ID ||
!process.env.CLOUDFLARE_API_TOKEN
) {
describe.skip("Skipping remote bindings tests without account credentials.");
} else {
describe
Expand Down Expand Up @@ -160,55 +169,41 @@ if (!process.env.CLOUDFLARE_ACCOUNT_ID || !process.env.CLOUDFLARE_API_TOKEN) {
});
});

describe("failure to connect to remote bindings", () => {
describe.skipIf(isWindows)("failure to connect to remote bindings", () => {
const projectPath = seed("remote-bindings-incorrect-r2-config", {
pm: "pnpm",
});

describe.each(commands)('with "%s" command', (command) => {
// On Windows the path for the miniflare dependency gets pretty long and this fails in node < 22.7
// (see: https://github.com/shellscape/jsx-email/issues/225#issuecomment-2420567832), so
// we need to skip this on windows since in CI we're using node 20
// we should look into re-enable this once we can move to a node a newer version of node
test.skipIf(process.platform === "win32")(
"exit with a non zero error code and log an error",
async () => {
const proc = await runLongLived("pnpm", command, projectPath);
test("exit with a non zero error code and log an error", async () => {
const proc = await runLongLived("pnpm", command, projectPath);

expect(await proc.exitCode).not.toBe(0);
expect(proc.stderr).toContain(
"R2 bucket 'non-existent-r2-bucket' not found. Please use a different name and try again. [code: 10085]"
);
expect(proc.stderr).toContain(
"Error: Failed to start the remote proxy session. There is likely additional logging output above."
);
}
);
expect(await proc.exitCode).not.toBe(0);
expect(proc.stderr).toContain(
"R2 bucket 'non-existent-r2-bucket' not found. Please use a different name and try again. [code: 10085]"
);
expect(proc.stderr).toContain(
"Error: Failed to start the remote proxy session. There is likely additional logging output above."
);
});
});
});
}

describe("remote bindings disabled", () => {
describe.skipIf(isWindows)("remote bindings disabled", () => {
const projectPath = seed("remote-bindings-disabled", { pm: "pnpm" });

describe.each(commands)('with "%s" command', (command) => {
// On Windows the path for the miniflare dependency gets pretty long and this fails in node < 22.7
// (see: https://github.com/shellscape/jsx-email/issues/225#issuecomment-2420567832), so
// we need to skip this on windows since in CI we're using node 20
// we should look into re-enable this once we can move to a node a newer version of node
Comment on lines -195 to -198

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

mh.... this comment is a bit useful, I think it is a bit of a shame to remove it as it could come in handy at some point... but it'd be a bit weird to move it up... 😓

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.

Node 20 support ends in April, so this will not be a problem soon-ish.

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.

In the long run, I would like to move away from testing remote-bindings e2e for most our our tools, since this is inherently flakey and I don't know how much value is being added by testing in miniflare, wrangler, and vite-plugin. In fact we moved a bunch of wrangler tests to mock out the remote binding bit and just test that wrangler sends the correct config to miniflare.

test.skipIf(process.platform === "win32")(
"cannot connect to remote bindings",
async () => {
const proc = await runLongLived("pnpm", command, projectPath);
const url = await waitForReady(proc);
test("cannot connect to remote bindings", async () => {
const proc = await runLongLived("pnpm", command, projectPath);
const url = await waitForReady(proc);

const response = await fetch(url);
const response = await fetch(url);

const responseText = await response.text();
const responseText = await response.text();

expect(responseText).toContain("Error");
expect(responseText).toContain("Binding AI needs to be run remotely");
}
);
expect(responseText).toContain("Error");
expect(responseText).toContain("Binding AI needs to be run remotely");
});
});
});
Loading