Skip to content

Commit

Permalink
Make everything concurrent at the 'describe' level
Browse files Browse the repository at this point in the history
  • Loading branch information
GregBrimble committed Jan 5, 2023
1 parent e2f1fda commit 1886c46
Show file tree
Hide file tree
Showing 13 changed files with 236 additions and 254 deletions.
59 changes: 28 additions & 31 deletions fixtures/external-durable-objects-app/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fetch } from "undici";
import { describe, expect, it, beforeAll, afterAll } from "vitest";
import type { ChildProcess } from "child_process";

describe.skip("Pages Functions", () => {
describe.concurrent.skip("Pages Functions", () => {
let aWranglerProcess: ChildProcess;
let aIP: string;
let aPort: number;
Expand Down Expand Up @@ -137,36 +137,33 @@ describe.skip("Pages Functions", () => {
});
});

it.concurrent(
"connects up Durable Objects and keeps state across wrangler instances",
async () => {
await aReadyPromise;
await bReadyPromise;
await cReadyPromise;
await dReadyPromise;
it("connects up Durable Objects and keeps state across wrangler instances", async () => {
await aReadyPromise;
await bReadyPromise;
await cReadyPromise;
await dReadyPromise;

// Service registry is polled every 300ms,
// so let's give all the Workers a little time to find each other
await new Promise((resolve) => setTimeout(resolve, 700));
// Service registry is polled every 300ms,
// so let's give all the Workers a little time to find each other
await new Promise((resolve) => setTimeout(resolve, 700));

const responseA = await fetch(`http://${aIP}:${aPort}/`);
const dataA = (await responseA.json()) as { count: number; id: string };
expect(dataA.count).toEqual(1);
const responseB = await fetch(`http://${bIP}:${bPort}/`);
const dataB = (await responseB.json()) as { count: number; id: string };
expect(dataB.count).toEqual(2);
const responseC = await fetch(`http://${cIP}:${cPort}/`);
const dataC = (await responseC.json()) as { count: number; id: string };
expect(dataC.count).toEqual(3);
const responseD = await fetch(`http://${dIP}:${dPort}/`);
const dataD = (await responseD.json()) as { count: number; id: string };
expect(dataD.count).toEqual(4);
const responseA2 = await fetch(`http://${aIP}:${aPort}/`);
const dataA2 = (await responseA2.json()) as { count: number; id: string };
expect(dataA2.count).toEqual(5);
expect(dataA.id).toEqual(dataB.id);
expect(dataA.id).toEqual(dataC.id);
expect(dataA.id).toEqual(dataA2.id);
}
);
const responseA = await fetch(`http://${aIP}:${aPort}/`);
const dataA = (await responseA.json()) as { count: number; id: string };
expect(dataA.count).toEqual(1);
const responseB = await fetch(`http://${bIP}:${bPort}/`);
const dataB = (await responseB.json()) as { count: number; id: string };
expect(dataB.count).toEqual(2);
const responseC = await fetch(`http://${cIP}:${cPort}/`);
const dataC = (await responseC.json()) as { count: number; id: string };
expect(dataC.count).toEqual(3);
const responseD = await fetch(`http://${dIP}:${dPort}/`);
const dataD = (await responseD.json()) as { count: number; id: string };
expect(dataD.count).toEqual(4);
const responseA2 = await fetch(`http://${aIP}:${aPort}/`);
const dataA2 = (await responseA2.json()) as { count: number; id: string };
expect(dataA2.count).toEqual(5);
expect(dataA.id).toEqual(dataB.id);
expect(dataA.id).toEqual(dataC.id);
expect(dataA.id).toEqual(dataA2.id);
});
});
19 changes: 9 additions & 10 deletions fixtures/node-app-pages/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fetch } from "undici";
import { describe, it, beforeAll, afterAll } from "vitest";
import type { ChildProcess } from "child_process";

describe("Pages Dev", () => {
describe.concurrent("Pages Dev", () => {
let wranglerProcess: ChildProcess;
let ip: string;
let port: number;
Expand Down Expand Up @@ -40,14 +40,13 @@ describe("Pages Dev", () => {
});
});

it.concurrent(
"should work with `--node-compat` when running code requiring polyfills",
async ({ expect }) => {
const response = await fetch(`http://${ip}:${port}/stripe`);
it("should work with `--node-compat` when running code requiring polyfills", async ({
expect,
}) => {
const response = await fetch(`http://${ip}:${port}/stripe`);

await expect(response.text()).resolves.toContain(
`"PATH":"path/to/some-file","STRIPE_OBJECT"`
);
}
);
await expect(response.text()).resolves.toContain(
`"PATH":"path/to/some-file","STRIPE_OBJECT"`
);
});
});
4 changes: 2 additions & 2 deletions fixtures/pages-d1-shim/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import * as path from "path";
import { join } from "path";
import { describe, it } from "vitest";

describe("Pages D1 shim", () => {
it.concurrent("applies the D1 shim", async ({ expect }) => {
describe.concurrent("Pages D1 shim", () => {
it("applies the D1 shim", async ({ expect }) => {
const dir = tmpdir();
const file = join(dir, "./d1-pages.js");

Expand Down
Loading

0 comments on commit 1886c46

Please sign in to comment.