diff --git a/.github/workflows/c3-checks.yml b/.github/workflows/c3-checks.yml deleted file mode 100644 index 4ff41ebd3bad..000000000000 --- a/.github/workflows/c3-checks.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: C3 Checks - -on: - pull_request: - paths: - - packages/create-cloudflare/** - -env: - node-version: 18.17.1 - -jobs: - check: - name: "Checks" - strategy: - matrix: - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Install Dependencies - uses: ./.github/actions/install-dependencies - - - name: Check Types - run: pnpm run --filter create-cloudflare check:type - - - name: Lint - run: pnpm run --filter create-cloudflare check:lint - - - name: Unit Tests - run: pnpm run --filter create-cloudflare test:unit diff --git a/.github/workflows/c3-e2e-project-cleanup.yml b/.github/workflows/c3-e2e-project-cleanup.yml index 4208bbb2278b..43573a6d7702 100644 --- a/.github/workflows/c3-e2e-project-cleanup.yml +++ b/.github/workflows/c3-e2e-project-cleanup.yml @@ -10,6 +10,7 @@ env: node-version: 18.17.1 jobs: cleanup: + timeout-minutes: 30 name: "Cleanup Test Projects" if: ${{ github.repository_owner == 'cloudflare' }} runs-on: ubuntu-latest diff --git a/.github/workflows/c3-e2e-quarantine.yml b/.github/workflows/c3-e2e-quarantine.yml index e2cafb9f30be..21a710931b99 100644 --- a/.github/workflows/c3-e2e-quarantine.yml +++ b/.github/workflows/c3-e2e-quarantine.yml @@ -12,7 +12,12 @@ env: bun-version: 1.0.3 jobs: e2e: + timeout-minutes: 30 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.pm }} + cancel-in-progress: true name: ${{ format('E2E ({0})', matrix.pm) }} + if: github.repository_owner == 'cloudflare' strategy: matrix: os: [ubuntu-latest] diff --git a/.github/workflows/c3-e2e.yml b/.github/workflows/c3-e2e.yml index ec736d345a65..dfc4a6fec06d 100644 --- a/.github/workflows/c3-e2e.yml +++ b/.github/workflows/c3-e2e.yml @@ -10,6 +10,10 @@ env: bun-version: 1.0.3 jobs: e2e: + timeout-minutes: 30 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.pm }} + cancel-in-progress: true name: ${{ format('E2E ({0})', matrix.pm) }} if: github.repository_owner == 'cloudflare' && github.event.pull_request.user.login != 'dependabot[bot]' strategy: diff --git a/.github/workflows/choose-pages-projects.yml b/.github/workflows/choose-pages-projects.yml index 4bd6ae5903c1..9e8d385c2f13 100644 --- a/.github/workflows/choose-pages-projects.yml +++ b/.github/workflows/choose-pages-projects.yml @@ -39,6 +39,8 @@ jobs: - name: Build run: pnpm run build + env: + CI_OS: ${{ runner.os }} - name: Build Quick Edit run: cd packages/quick-edit && yarn setup && yarn custom:build diff --git a/.github/workflows/codecov-context.yml b/.github/workflows/codecov-context.yml index 41230a4a8318..db67f89742f3 100644 --- a/.github/workflows/codecov-context.yml +++ b/.github/workflows/codecov-context.yml @@ -38,6 +38,7 @@ jobs: run: pnpm run build env: NODE_ENV: "production" + CI_OS: ${{ runner.os }} - name: Run tests & collect coverage run: pnpm run --filter wrangler test:ci diff --git a/.github/workflows/create-pullrequest-prerelease.yml b/.github/workflows/create-pullrequest-prerelease.yml index d9ef80ec1877..0075e383804e 100644 --- a/.github/workflows/create-pullrequest-prerelease.yml +++ b/.github/workflows/create-pullrequest-prerelease.yml @@ -7,7 +7,10 @@ jobs: if: ${{ github.repository_owner == 'cloudflare' }} name: Build & Publish a Prerelease to the Adhoc Registry runs-on: ubuntu-latest - + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + timeout-minutes: 30 steps: - name: Checkout Repo uses: actions/checkout@v3 @@ -36,6 +39,8 @@ jobs: # `extract-runtime-versions.mjs` needs to be able to resolve `miniflare`, but we want to have the correct # `package.json` versions when we build packages for packing run: pnpm run build --filter miniflare + env: + CI_OS: ${{ runner.os }} - name: Extract runtime versions run: node .github/extract-runtime-versions.mjs # extract versions before modifying version to include commit hash @@ -63,6 +68,7 @@ jobs: NODE_ENV: "production" ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} ALGOLIA_PUBLIC_KEY: ${{ secrets.ALGOLIA_PUBLIC_KEY }} + CI_OS: ${{ runner.os }} - name: Pack miniflare run: pnpm pack diff --git a/.github/workflows/d1.yml b/.github/workflows/d1.yml deleted file mode 100644 index 40f5188cb148..000000000000 --- a/.github/workflows/d1.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: D1 -on: - push: - branches: - - d1 - -jobs: - release: - if: ${{ github.repository_owner == 'cloudflare' }} - name: Release - runs-on: ubuntu-latest - - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: pnpm/action-setup@v2 - with: - version: 8.8.0 - - name: Use Node.js 16.18 - uses: actions/setup-node@v3 - with: - node-version: 16.18 - cache: "pnpm" - - - name: Install workerd Dependencies - if: ${{ runner.os == 'Linux' }} - run: | - export DEBIAN_FRONTEND=noninteractive - sudo apt-get update - sudo apt-get install -y libc++1 - - - name: Install NPM Dependencies - run: pnpm install --frozen-lockfile - - - name: Build - run: pnpm run build - - - name: Check for errors - run: pnpm run check - env: - NODE_OPTIONS: "--max_old_space_size=8192" - - - name: Modify package.json version - run: node .github/version-script.js - - - name: Publish to NPM - run: pnpm publish --tag d1 - env: - NODE_ENV: "production" - NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - working-directory: packages/wrangler diff --git a/.github/workflows/deploy-pages-project.yml b/.github/workflows/deploy-pages-project.yml index 93dc67a407a4..fb72904baf2b 100644 --- a/.github/workflows/deploy-pages-project.yml +++ b/.github/workflows/deploy-pages-project.yml @@ -12,6 +12,10 @@ on: jobs: publish: + timeout-minutes: 30 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.package }} + cancel-in-progress: true runs-on: ubuntu-latest steps: - name: Checkout Repo @@ -24,6 +28,8 @@ jobs: - name: Build run: pnpm run build + env: + CI_OS: ${{ runner.os }} - name: Deploy to Pages run: pnpm --filter ${{ inputs.package }} run deploy diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index eb43a1444180..5e84c1893c4b 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -3,7 +3,6 @@ name: E2E tests on: push: branches: - - main - changeset-release/main pull_request: types: [synchronize, opened, reopened, labeled, unlabeled] @@ -11,21 +10,17 @@ on: jobs: e2e-test: - if: github.repository_owner == 'cloudflare' && (github.event_name != 'pull_request' || (github.event_name == 'pull_request' && contains(github.event.*.labels.*.name, 'e2e' )) || (github.event_name == 'pull_request' && github.head_ref == 'changeset-release/main')) + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.node }} + cancel-in-progress: true + timeout-minutes: 30 + if: github.repository_owner == 'cloudflare' && (github.event_name != 'pull_request' || (github.event_name == 'pull_request' && contains(github.event.*.labels.*.name, 'e2e' ))) name: "E2E Test" strategy: fail-fast: false matrix: - os: [ - # macos-11, - # macos-12, - macos-13, - windows-2019, - windows-2022, - # ubuntu-20.04, - ubuntu-22.04, - ] - node: ["16", "18"] + os: [macos-13, windows-2022, ubuntu-22.04] + node: ["18"] runs-on: ${{ matrix.os }} steps: - name: Checkout Repo @@ -55,6 +50,7 @@ jobs: run: pnpm run build env: NODE_ENV: "production" + CI_OS: ${{ runner.os }} - name: Build Wrangler package for npm run: pnpm pack --pack-destination $HOME diff --git a/.github/workflows/edge-preview-authenticated-proxy.yml b/.github/workflows/edge-preview-authenticated-proxy.yml index 2aadbe270043..6af1c8e4972a 100644 --- a/.github/workflows/edge-preview-authenticated-proxy.yml +++ b/.github/workflows/edge-preview-authenticated-proxy.yml @@ -38,6 +38,7 @@ jobs: run: pnpm run build env: NODE_ENV: "production" + CI_OS: ${{ runner.os }} - name: Build & Publish Worker run: pnpm run publish diff --git a/.github/workflows/experimental-wasm-release.yml b/.github/workflows/experimental-wasm-release.yml deleted file mode 100644 index 0912b14ee580..000000000000 --- a/.github/workflows/experimental-wasm-release.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: WASM Experimental builds -on: - push: - branches: - - experimental-wasm -jobs: - build: - if: ${{ github.repository_owner == 'cloudflare' }} - name: Build and release `wrangler@wasm` to NPM - runs-on: ubuntu-latest - - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: pnpm/action-setup@v2 - with: - version: 8.8.0 - - name: Use Node.js 16.18 - uses: actions/setup-node@v3 - with: - node-version: 16.18 - cache: "pnpm" - - - name: Install workerd Dependencies - if: ${{ runner.os == 'Linux' }} - run: | - export DEBIAN_FRONTEND=noninteractive - sudo apt-get update - sudo apt-get install -y libc++1 - - - name: Install NPM Dependencies - run: pnpm install --frozen-lockfile - - - name: Modify package.json version - run: node .github/version-script.js - - - name: Build - run: pnpm run build - - - name: Check for errors - run: pnpm run check - env: - NODE_OPTIONS: "--max_old_space_size=8192" - - - name: Publish `wrangler@wasm` to NPM - run: pnpm publish --tag wasm - env: - NODE_ENV: "production" - NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - working-directory: packages/wrangler diff --git a/.github/workflows/format-errors.yml b/.github/workflows/format-errors.yml index 9f5bce171707..fb4966b2e1ca 100644 --- a/.github/workflows/format-errors.yml +++ b/.github/workflows/format-errors.yml @@ -37,6 +37,7 @@ jobs: run: pnpm run build env: NODE_ENV: "production" + CI_OS: ${{ runner.os }} - name: Build & Publish Worker run: pnpm run publish diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index abfe1e34c21a..ac97737a7c41 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,10 @@ on: jobs: test: + timeout-minutes: 30 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }} + cancel-in-progress: true if: ${{ github.repository_owner == 'cloudflare' }} name: "Tests" strategy: @@ -43,6 +47,7 @@ jobs: run: pnpm run build env: NODE_ENV: "production" + CI_OS: ${{ runner.os }} - name: Check for errors run: pnpm run check diff --git a/.github/workflows/playground-preview-worker.yml b/.github/workflows/playground-preview-worker.yml index f21c859a68b5..0b76e9d1da96 100644 --- a/.github/workflows/playground-preview-worker.yml +++ b/.github/workflows/playground-preview-worker.yml @@ -38,6 +38,7 @@ jobs: run: pnpm run build env: NODE_ENV: "production" + CI_OS: ${{ runner.os }} - name: Build & Publish Worker run: pnpm run deploy diff --git a/.github/workflows/playground-worker-tests.yml b/.github/workflows/playground-worker-tests.yml index 97aff98bbe4f..2d8d8cca3106 100644 --- a/.github/workflows/playground-worker-tests.yml +++ b/.github/workflows/playground-worker-tests.yml @@ -42,6 +42,7 @@ jobs: run: pnpm run build env: NODE_ENV: "production" + CI_OS: ${{ runner.os }} - name: Build & Publish Testing Playground Worker run: pnpm run deploy:testing diff --git a/.github/workflows/prerelease-create-cloudflare.yml b/.github/workflows/prerelease-create-cloudflare.yml index 2ee419ce71c0..9a3a930540a1 100644 --- a/.github/workflows/prerelease-create-cloudflare.yml +++ b/.github/workflows/prerelease-create-cloudflare.yml @@ -44,6 +44,7 @@ jobs: run: pnpm run build env: NODE_ENV: "production" + CI_OS: ${{ runner.os }} - name: Publish Beta to NPM run: pnpm publish --tag beta diff --git a/.github/workflows/prereleases.yml b/.github/workflows/prereleases.yml index f8dd7c6ff3bb..ebf660851c2a 100644 --- a/.github/workflows/prereleases.yml +++ b/.github/workflows/prereleases.yml @@ -6,6 +6,10 @@ on: - main jobs: prerelease: + timeout-minutes: 30 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true if: ${{ github.repository_owner == 'cloudflare' }} name: Build & Publish a beta release to NPM runs-on: ubuntu-latest @@ -49,6 +53,7 @@ jobs: run: pnpm run build env: NODE_ENV: "production" + CI_OS: ${{ runner.os }} - name: Check for errors run: pnpm run check @@ -70,6 +75,7 @@ jobs: working-directory: packages/wrangler publish_prerelease_registry: + timeout-minutes: 30 if: ${{ github.repository_owner == 'cloudflare' }} name: Publish Prerelease Registry needs: prerelease @@ -105,6 +111,7 @@ jobs: NODE_ENV: "production" ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} ALGOLIA_PUBLIC_KEY: ${{ secrets.ALGOLIA_PUBLIC_KEY }} + CI_OS: ${{ runner.os }} - name: Build & Publish Prerelease Registry run: pnpm run publish diff --git a/.github/workflows/pullrequests.yml b/.github/workflows/pullrequests.yml index a12705d32a1c..35b30a5cc7dc 100644 --- a/.github/workflows/pullrequests.yml +++ b/.github/workflows/pullrequests.yml @@ -6,12 +6,21 @@ env: node-version: 16.18 jobs: add-to-project: + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-add-pr + cancel-in-progress: true + timeout-minutes: 30 name: Add PR to project runs-on: ubuntu-latest steps: - run: curl -X POST https://devprod-status-bot.devprod.workers.dev/pr-project/workers-sdk/${{ github.event.number }} check: + timeout-minutes: 30 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-checks + cancel-in-progress: true + name: "Checks" runs-on: ubuntu-latest steps: @@ -50,6 +59,8 @@ jobs: - name: Build run: pnpm run build + env: + CI_OS: ${{ runner.os }} - name: Check for errors run: pnpm run check @@ -57,6 +68,11 @@ jobs: NODE_OPTIONS: "--max_old_space_size=8192" test: + timeout-minutes: 30 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-test + cancel-in-progress: true + name: "Tests" strategy: matrix: @@ -91,6 +107,7 @@ jobs: run: pnpm run build env: NODE_ENV: "production" + CI_OS: ${{ runner.os }} - name: Run tests & collect coverage run: pnpm run test:ci @@ -104,46 +121,3 @@ jobs: - name: Report Code Coverage uses: codecov/codecov-action@v3 - - quarantine: - name: "Quarantined Tests" - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: pnpm/action-setup@v2 - with: - version: 8.8.0 - - name: Use Node.js ${{ env.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.node-version }} - cache: "pnpm" - - - name: "Create .env file" - run: | - touch .env - echo TURBO_API=${{ secrets.TURBO_API }} >> .env - echo TURBO_TEAM=${{ secrets.TURBO_TEAM }} >> .env - echo TURBO_TOKEN=${{ secrets.TURBO_TOKEN }} >> .env - echo TURBO_REMOTE_CACHE_SIGNATURE_KEY=${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }} >> .env - - - name: Install NPM Dependencies - run: pnpm install --frozen-lockfile - - - name: Run builds - run: pnpm run build - env: - NODE_ENV: "production" - - - name: Run tests - run: pnpm run test:ci:quarantine - env: - TMP_CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - TMP_CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - NODE_OPTIONS: "--max_old_space_size=8192" diff --git a/.github/workflows/queues.yml b/.github/workflows/queues.yml deleted file mode 100644 index 617e12ba45f0..000000000000 --- a/.github/workflows/queues.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Queues Experimental builds -on: - push: - branches: - - queues - -jobs: - build: - if: ${{ github.repository_owner == 'cloudflare' }} - name: Build and release `wrangler@queues` to NPM - runs-on: ubuntu-latest - - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: pnpm/action-setup@v2 - with: - version: 8.8.0 - - name: Use Node.js 16.18 - uses: actions/setup-node@v3 - with: - node-version: 16.18 - cache: "pnpm" - - - name: Install workerd Dependencies - if: ${{ runner.os == 'Linux' }} - run: | - export DEBIAN_FRONTEND=noninteractive - sudo apt-get update - sudo apt-get install -y libc++1 - - - name: Install NPM Dependencies - run: pnpm install --frozen-lockfile - - - name: Build - run: pnpm run build - - - name: Check for errors - run: pnpm run check - env: - NODE_OPTIONS: "--max_old_space_size=8192" - - - name: Modify package.json version - run: node .github/version-script.js - - - name: Publish `wrangler@queues` to NPM - run: pnpm publish --tag queues - env: - NODE_ENV: "production" - NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - working-directory: packages/wrangler diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65b7863ffdde..7888de18d00d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,11 @@ on: jobs: release: + timeout-minutes: 30 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + if: ${{ github.repository_owner == 'cloudflare' }} name: Release runs-on: ubuntu-latest @@ -38,6 +43,8 @@ jobs: - name: Check the build run: pnpm run build + env: + CI_OS: ${{ runner.os }} - name: Check for other errors run: pnpm run check diff --git a/.github/workflows/test-old-node-error.yml b/.github/workflows/test-old-node-error.yml index 91dd7d3dd940..9d4c773fcda2 100644 --- a/.github/workflows/test-old-node-error.yml +++ b/.github/workflows/test-old-node-error.yml @@ -5,6 +5,10 @@ on: pull_request jobs: check: name: "Checks" + timeout-minutes: 30 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }} + cancel-in-progress: true strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] diff --git a/ensure-turbo-build-output.mjs b/ensure-turbo-build-output.mjs new file mode 100644 index 000000000000..89b276271b8b --- /dev/null +++ b/ensure-turbo-build-output.mjs @@ -0,0 +1,33 @@ +import assert from "assert"; +import { execSync } from "child_process"; +import { readFileSync } from "fs"; +import path from "path"; + +function readJson(filePath) { + return JSON.parse(readFileSync(filePath, "utf8")); +} + +const listResult = execSync( + "pnpm --filter=!wrangler-root list --recursive --depth -1 --parseable" +); +const paths = listResult.toString().trim().split("\n"); +for (const p of paths) { + if (!path.isAbsolute(p)) continue; + + const pkg = readJson(path.join(p, "package.json")); + + // Ensure all packages with a build script have a turbo build output configured + + if (pkg.scripts?.build) { + console.log(pkg.name, "has build script. Checking turbo.json"); + let turboConfig; + try { + turboConfig = readJson(path.join(p, "turbo.json")); + } catch { + console.log("Failed to read turbo.json for", pkg.name); + process.exit(1); + } + const buildOutputs = turboConfig.pipeline.build.outputs; + assert(buildOutputs.length > 0); + } +} diff --git a/fixtures/additional-modules/package.json b/fixtures/additional-modules/package.json index eaa994372e27..83ae898b8797 100644 --- a/fixtures/additional-modules/package.json +++ b/fixtures/additional-modules/package.json @@ -8,7 +8,6 @@ "deploy": "wrangler deploy", "start": "wrangler dev", "test": "vitest run", - "test:ci": "vitest run", "test:watch": "vitest", "type:tests": "tsc -p ./test/tsconfig.json" }, diff --git a/fixtures/additional-modules/turbo.json b/fixtures/additional-modules/turbo.json new file mode 100644 index 000000000000..1a6c74c9def8 --- /dev/null +++ b/fixtures/additional-modules/turbo.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://turbo.build/schema.json", + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["dist/**"] + } + } +} diff --git a/fixtures/additional-modules/vitest.config.ts b/fixtures/additional-modules/vitest.config.ts new file mode 100644 index 000000000000..eeb631d13660 --- /dev/null +++ b/fixtures/additional-modules/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 15_000, + hookTimeout: 15_000, + teardownTimeout: 15_000, + useAtomics: true, + }, +}); diff --git a/fixtures/external-durable-objects-app/a/index.ts b/fixtures/external-durable-objects-app/a/index.ts index a50d5981e081..a69ad1aaa71f 100644 --- a/fixtures/external-durable-objects-app/a/index.ts +++ b/fixtures/external-durable-objects-app/a/index.ts @@ -10,7 +10,10 @@ export default { export class MyDurableObject implements DurableObject { constructor(public state: DurableObjectState) {} - async fetch() { + async fetch(request: Request) { + if (request.headers.has("X-Reset-Count")) { + await this.state.storage.put("count", 0); + } let count: number = (await this.state.storage.get("count")) || 0; await this.state.storage.put("count", ++count); return Response.json({ count, id: this.state.id.toString() }); diff --git a/fixtures/external-durable-objects-app/package.json b/fixtures/external-durable-objects-app/package.json index a3ec0df9ce90..32ea12c0059a 100644 --- a/fixtures/external-durable-objects-app/package.json +++ b/fixtures/external-durable-objects-app/package.json @@ -5,9 +5,8 @@ "scripts": { "check:type": "tsc", "dev": "npx concurrently -s first -k \"wrangler dev a/index.ts --local --port 8400\" \"wrangler dev b/index.ts --local --port 8401\" \"npx wrangler dev c/index.ts --local --port 8402\" \"cd d && npx wrangler pages dev public --port 8403 --do PAGES_REFERENCED_DO=MyDurableObject@a\"", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/external-durable-objects-app/tests/index.test.ts b/fixtures/external-durable-objects-app/tests/index.test.ts index 55428a6902bb..04f7566e8d88 100644 --- a/fixtures/external-durable-objects-app/tests/index.test.ts +++ b/fixtures/external-durable-objects-app/tests/index.test.ts @@ -3,29 +3,13 @@ import * as path from "path"; import { fetch } from "undici"; import { describe, expect, it, beforeAll, afterAll } from "vitest"; import type { ChildProcess } from "child_process"; +import { type UnstableDevWorker, unstable_dev } from "wrangler"; + +describe("Pages Functions", () => { + let a: UnstableDevWorker; + let b: UnstableDevWorker; + let c: UnstableDevWorker; -describe.skip("Pages Functions", () => { - let aWranglerProcess: ChildProcess; - let aIP: string; - let aPort: number; - let aResolveReadyPromise: (value: unknown) => void; - const aReadyPromise = new Promise((resolve) => { - aResolveReadyPromise = resolve; - }); - let bWranglerProcess: ChildProcess; - let bIP: string; - let bPort: number; - let bResolveReadyPromise: (value: unknown) => void; - const bReadyPromise = new Promise((resolve) => { - bResolveReadyPromise = resolve; - }); - let cWranglerProcess: ChildProcess; - let cIP: string; - let cPort: number; - let cResolveReadyPromise: (value: unknown) => void; - const cReadyPromise = new Promise((resolve) => { - cResolveReadyPromise = resolve; - }); let dWranglerProcess: ChildProcess; let dIP: string; let dPort: number; @@ -34,46 +18,18 @@ describe.skip("Pages Functions", () => { dResolveReadyPromise = resolve; }); - beforeAll(() => { - aWranglerProcess = fork( - path.join("..", "..", "..", "packages", "wrangler", "bin", "wrangler.js"), - ["dev", "index.ts", "--local", "--port=0"], - { - stdio: ["ignore", "ignore", "ignore", "ipc"], - cwd: path.resolve(__dirname, "..", "a"), - } - ).on("message", (message) => { - const parsedMessage = JSON.parse(message.toString()); - aIP = parsedMessage.ip; - aPort = parsedMessage.port; - aResolveReadyPromise(undefined); + beforeAll(async () => { + a = await unstable_dev(path.join(__dirname, "../a/index.ts"), { + config: path.join(__dirname, "../a/wrangler.toml"), }); - bWranglerProcess = fork( - path.join("..", "..", "..", "packages", "wrangler", "bin", "wrangler.js"), - ["dev", "index.ts", "--local", "--port=0"], - { - stdio: ["ignore", "ignore", "ignore", "ipc"], - cwd: path.resolve(__dirname, "..", "b"), - } - ).on("message", (message) => { - const parsedMessage = JSON.parse(message.toString()); - bIP = parsedMessage.ip; - bPort = parsedMessage.port; - bResolveReadyPromise(undefined); + b = await unstable_dev(path.join(__dirname, "../b/index.ts"), { + config: path.join(__dirname, "../b/wrangler.toml"), }); - cWranglerProcess = fork( - path.join("..", "..", "..", "packages", "wrangler", "bin", "wrangler.js"), - ["dev", "index.ts", "--local", "--port=0"], - { - stdio: ["ignore", "ignore", "ignore", "ipc"], - cwd: path.resolve(__dirname, "..", "c"), - } - ).on("message", (message) => { - const parsedMessage = JSON.parse(message.toString()); - cIP = parsedMessage.ip; - cPort = parsedMessage.port; - cResolveReadyPromise(undefined); + + c = await unstable_dev(path.join(__dirname, "../c/index.ts"), { + config: path.join(__dirname, "../c/wrangler.toml"), }); + dWranglerProcess = fork( path.join("..", "..", "..", "packages", "wrangler", "bin", "wrangler.js"), [ @@ -96,36 +52,12 @@ describe.skip("Pages Functions", () => { }); afterAll(async () => { - await aReadyPromise; - await bReadyPromise; - await cReadyPromise; await dReadyPromise; + await a.stop(); + await b.stop(); + await c.stop(); await new Promise((resolve, reject) => { - aWranglerProcess.once("exit", (code) => { - if (!code) { - resolve(code); - } else { - reject(code); - } - }); - aWranglerProcess.kill("SIGTERM"); - bWranglerProcess.once("exit", (code) => { - if (!code) { - resolve(code); - } else { - reject(code); - } - }); - bWranglerProcess.kill("SIGTERM"); - cWranglerProcess.once("exit", (code) => { - if (!code) { - resolve(code); - } else { - reject(code); - } - }); - cWranglerProcess.kill("SIGTERM"); dWranglerProcess.once("exit", (code) => { if (!code) { resolve(code); @@ -138,28 +70,29 @@ describe.skip("Pages Functions", () => { }); 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)); - const responseA = await fetch(`http://${aIP}:${aPort}/`); + const responseA = await a.fetch(`/`, { + headers: { + "X-Reset-Count": "true", + }, + }); const dataA = (await responseA.json()) as { count: number; id: string }; expect(dataA.count).toEqual(1); - const responseB = await fetch(`http://${bIP}:${bPort}/`); + const responseB = await b.fetch(`/`); const dataB = (await responseB.json()) as { count: number; id: string }; expect(dataB.count).toEqual(2); - const responseC = await fetch(`http://${cIP}:${cPort}/`); + const responseC = await c.fetch(`/`); 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 responseA2 = await a.fetch(`/`); const dataA2 = (await responseA2.json()) as { count: number; id: string }; expect(dataA2.count).toEqual(5); expect(dataA.id).toEqual(dataB.id); diff --git a/fixtures/external-durable-objects-app/vitest.config.ts b/fixtures/external-durable-objects-app/vitest.config.ts new file mode 100644 index 000000000000..74c6ea85d13a --- /dev/null +++ b/fixtures/external-durable-objects-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 25_000, + hookTimeout: 25_000, + teardownTimeout: 25_000, + useAtomics: true, + }, +}); diff --git a/fixtures/external-service-bindings-app/package.json b/fixtures/external-service-bindings-app/package.json index 57b56511f9c0..5c02bd9d6c46 100644 --- a/fixtures/external-service-bindings-app/package.json +++ b/fixtures/external-service-bindings-app/package.json @@ -10,9 +10,8 @@ "mod-d-dev": "wrangler dev module-worker-d/index.ts --local --port 8504 --env production", "pages-dev": "cd pages-functions-app && npx wrangler pages dev public --port 8505 --service MODULE_A_SERVICE=module-worker-a MODULE_B_SERVICE=module-worker-b SERVICE_A_SERVICE=service-worker-a STAGING_MODULE_C_SERVICE=module-worker-c@staging STAGING_MODULE_D_SERVICE=module-worker-d@staging", "dev": "npx concurrently -s first -k 'npm run mod-a-dev' 'npm run mod-b-dev' 'npm run ser-a-dev' 'npm run mod-c-dev' 'npm run mod-d-dev' 'npm run pages-dev'", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc --noEmit" }, "devDependencies": { diff --git a/fixtures/external-service-bindings-app/tests/index.test.ts b/fixtures/external-service-bindings-app/tests/index.test.ts index 2ccd7308b021..498df1767774 100644 --- a/fixtures/external-service-bindings-app/tests/index.test.ts +++ b/fixtures/external-service-bindings-app/tests/index.test.ts @@ -4,6 +4,7 @@ import type { ChildProcess } from "child_process"; import { describe, expect, it, beforeAll, afterAll, beforeEach } from "vitest"; import { fetch, type Response } from "undici"; import { setTimeout } from "node:timers/promises"; +import { type UnstableDevWorker, unstable_dev } from "wrangler"; const waitUntilReady = async (url: string): Promise => { let response: Response | undefined = undefined; @@ -27,49 +28,63 @@ type WranglerInstance = { }; describe("Pages Functions", () => { - let wranglerInstances: WranglerInstance[] = []; + let wranglerInstances: (WranglerInstance | UnstableDevWorker)[] = []; let pagesAppPort: string; beforeAll(async () => { - wranglerInstances = await Promise.all( - [ - { - dirName: "module-worker-a", - }, - { - dirName: "module-worker-b", - }, - { - dirName: "service-worker-a", - }, - { - dirName: "module-worker-c", - extraArgs: ["--env=staging"], - }, - { - dirName: "module-worker-d", - extraArgs: ["--env=production"], - }, - { - pages: true, - dirName: "pages-functions-app", - extraArgs: [ - "--service=MODULE_A_SERVICE=module-worker-a", - "--service=MODULE_B_SERVICE=module-worker-b", - "--service=SERVICE_A_SERVICE=service-worker-a", - "--service=STAGING_MODULE_C_SERVICE=module-worker-c@staging", - "--service=STAGING_MODULE_D_SERVICE=module-worker-d@staging", - ], - }, - ].map(getWranglerInstance) + wranglerInstances[0] = await unstable_dev( + path.join(__dirname, "../module-worker-a/index.ts"), + { + config: path.join(__dirname, "../module-worker-a/wrangler.toml"), + } + ); + wranglerInstances[1] = await unstable_dev( + path.join(__dirname, "../module-worker-b/index.ts"), + { + config: path.join(__dirname, "../module-worker-b/wrangler.toml"), + } ); - pagesAppPort = - wranglerInstances.find(({ dirName }) => dirName === "pages-functions-app") - ?.port ?? "0"; + wranglerInstances[2] = await unstable_dev( + path.join(__dirname, "../service-worker-a/index.ts"), + { + config: path.join(__dirname, "../service-worker-a/wrangler.toml"), + } + ); + wranglerInstances[3] = await unstable_dev( + path.join(__dirname, "../module-worker-c/index.ts"), + { + config: path.join(__dirname, "../module-worker-c/wrangler.toml"), + env: "staging", + } + ); + wranglerInstances[4] = await unstable_dev( + path.join(__dirname, "../module-worker-d/index.ts"), + { + config: path.join(__dirname, "../module-worker-d/wrangler.toml"), + env: "production", + } + ); + wranglerInstances[5] = await getWranglerInstance({ + pages: true, + dirName: "pages-functions-app", + extraArgs: [ + "--service=MODULE_A_SERVICE=module-worker-a", + "--service=MODULE_B_SERVICE=module-worker-b", + "--service=SERVICE_A_SERVICE=service-worker-a", + "--service=STAGING_MODULE_C_SERVICE=module-worker-c@staging", + "--service=STAGING_MODULE_D_SERVICE=module-worker-d@staging", + ], + }); + + pagesAppPort = wranglerInstances[5].port; }); afterAll(async () => { - await Promise.allSettled(wranglerInstances.map(terminateWranglerInstance)); + await Promise.allSettled( + wranglerInstances.map((i) => + "stop" in i ? i.stop() : terminateWranglerInstance(i) + ) + ); }); it("connects up Workers (both module and service ones) and fetches from them", async () => { diff --git a/fixtures/external-service-bindings-app/vitest.config.ts b/fixtures/external-service-bindings-app/vitest.config.ts new file mode 100644 index 000000000000..74c6ea85d13a --- /dev/null +++ b/fixtures/external-service-bindings-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 25_000, + hookTimeout: 25_000, + teardownTimeout: 25_000, + useAtomics: true, + }, +}); diff --git a/fixtures/import-wasm-example/package.json b/fixtures/import-wasm-example/package.json index 2e937b5c3cfc..1cffd5c793ba 100644 --- a/fixtures/import-wasm-example/package.json +++ b/fixtures/import-wasm-example/package.json @@ -7,9 +7,8 @@ "main": "src/index.js", "scripts": { "check:type": "tsc", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/import-wasm-example/tsconfig.json b/fixtures/import-wasm-example/tsconfig.json index 6eb14e3584b7..874dec6ac33a 100644 --- a/fixtures/import-wasm-example/tsconfig.json +++ b/fixtures/import-wasm-example/tsconfig.json @@ -6,7 +6,8 @@ "lib": ["ES2020"], "types": ["node"], "moduleResolution": "node", - "noEmit": true + "noEmit": true, + "skipLibCheck": true }, "include": ["tests", "../../node-types.d.ts"] } diff --git a/fixtures/import-wasm-example/vitest.config.ts b/fixtures/import-wasm-example/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/import-wasm-example/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/local-mode-tests/package.json b/fixtures/local-mode-tests/package.json index ed90c325946a..cf51810213d0 100644 --- a/fixtures/local-mode-tests/package.json +++ b/fixtures/local-mode-tests/package.json @@ -9,9 +9,8 @@ "main": "index.js", "scripts": { "check:type": "tsc", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/local-mode-tests/src/basicModule.ts b/fixtures/local-mode-tests/src/basicModule.ts deleted file mode 100644 index f28cf44c8650..000000000000 --- a/fixtures/local-mode-tests/src/basicModule.ts +++ /dev/null @@ -1,5 +0,0 @@ -export default { - async fetch() { - return new Response("Hello World!"); - }, -}; diff --git a/fixtures/local-mode-tests/src/headers.ts b/fixtures/local-mode-tests/src/headers.ts deleted file mode 100644 index deb74254c8b3..000000000000 --- a/fixtures/local-mode-tests/src/headers.ts +++ /dev/null @@ -1,37 +0,0 @@ -export default { - async fetch(req: Request): Promise { - let greeting = "Hi!"; - const { headers } = req; - - switch (headers.get("lang")) { - case "fr-FR": - greeting = "Bonjour!"; - break; - case "en-AU": - greeting = "G'day!"; - break; - case "en-US": - greeting = "Hello!"; - break; - case "en-GB": - greeting = "Good day!"; - break; - //en-TX isn't a real locale, but it's a fun one to have - case "en-TX": - greeting = "Howdy!"; - break; - case "es-ES": - greeting = "Hola!"; - break; - - default: - break; - } - - return new Response( - JSON.stringify({ - greeting, - }) - ); - }, -}; diff --git a/fixtures/local-mode-tests/src/module.ts b/fixtures/local-mode-tests/src/module.ts index c5ccdfe412b4..91099857caa0 100644 --- a/fixtures/local-mode-tests/src/module.ts +++ b/fixtures/local-mode-tests/src/module.ts @@ -1,29 +1,75 @@ +// Because we have the `buffer` npm package installed, this shouldn't fail, +// as esbuild can resolve that instead: +// https://github.com/cloudflare/workers-sdk/issues/2038 +import { Buffer } from "buffer"; + // @ts-expect-error non standard module -import data from "../some-data.bin"; +import data from "./some-data.bin"; // @ts-expect-error non standard module -import text from "../some-text.txt"; +import text from "./some-text.txt"; -declare global { - const process: { env: { NODE_ENV: string } }; -} +type Env = { + VAR1: string; + VAR2: string; + VAR3: string; + VAR4: string; +}; export default { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - async fetch(_request: Request, env: any): Promise { + async fetch(request: Request, env: Env): Promise { + const url = new URL(request.url); + let greeting = "Hi!"; + + switch (request.headers.get("lang")) { + case "fr-FR": + greeting = "Bonjour!"; + break; + case "en-AU": + greeting = "G'day!"; + break; + case "en-US": + greeting = "Hello!"; + break; + case "en-GB": + greeting = "Good day!"; + break; + //en-TX isn't a real locale, but it's a fun one to have + case "en-TX": + greeting = "Howdy!"; + break; + case "es-ES": + greeting = "Hola!"; + break; + + default: + break; + } + + if (url.pathname === "/vars") { + return new Response( + JSON.stringify( + { + VAR1: env.VAR1, + VAR2: env.VAR2, + VAR3: env.VAR3, + VAR4: env.VAR4, + text, + data: new TextDecoder().decode(data), + NODE_ENV: process.env.NODE_ENV, + }, + null, + 2 + ) + ); + } + if (url.pathname === "/buffer") { + return new Response(Buffer.from("hello").toString("hex")); + } + return new Response( - JSON.stringify( - { - VAR1: env.VAR1, - VAR2: env.VAR2, - VAR3: env.VAR3, - VAR4: env.VAR4, - text, - data: new TextDecoder().decode(data), - NODE_ENV: process.env.NODE_ENV, - }, - null, - 2 - ) + JSON.stringify({ + greeting, + }) ); }, }; diff --git a/fixtures/local-mode-tests/src/nodeBuiltinPackage.ts b/fixtures/local-mode-tests/src/nodeBuiltinPackage.ts deleted file mode 100644 index f28a3edd9fc7..000000000000 --- a/fixtures/local-mode-tests/src/nodeBuiltinPackage.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Because we have the `buffer` npm package installed, this shouldn't fail, -// as esbuild can resolve that instead: -// https://github.com/cloudflare/workers-sdk/issues/2038 -import { Buffer } from "buffer"; - -export default { - fetch() { - return new Response(Buffer.from("hello").toString("hex")); - }, -}; diff --git a/fixtures/local-mode-tests/some-data.bin b/fixtures/local-mode-tests/src/some-data.bin similarity index 100% rename from fixtures/local-mode-tests/some-data.bin rename to fixtures/local-mode-tests/src/some-data.bin diff --git a/fixtures/local-mode-tests/some-text.txt b/fixtures/local-mode-tests/src/some-text.txt similarity index 100% rename from fixtures/local-mode-tests/some-text.txt rename to fixtures/local-mode-tests/src/some-text.txt diff --git a/fixtures/local-mode-tests/src/sw.ts b/fixtures/local-mode-tests/src/sw.ts index 346cebb070f2..bbc830d1eda7 100644 --- a/fixtures/local-mode-tests/src/sw.ts +++ b/fixtures/local-mode-tests/src/sw.ts @@ -1,7 +1,7 @@ // @ts-expect-error non standard module -import data from "../some-data.bin"; +import data from "./some-data.bin"; // @ts-expect-error non standard module -import text from "../some-text.txt"; +import text from "./some-text.txt"; addEventListener("fetch", (event: FetchEvent) => { event.respondWith(handleRequest(event.request)); diff --git a/fixtures/local-mode-tests/src/wrangler.dotenv.toml b/fixtures/local-mode-tests/src/wrangler.dotenv.toml deleted file mode 100644 index 8f8f6b5c050a..000000000000 --- a/fixtures/local-mode-tests/src/wrangler.dotenv.toml +++ /dev/null @@ -1,6 +0,0 @@ -name = "local-mode-tests" -compatibility_date = "2022-03-27" - -# This custom build command will show whether the FOO -# environment variable was read from the `.env` file. -build.command = "node -e \"console.log(process.env.FOO)\"" diff --git a/fixtures/local-mode-tests/tests/headers.test.ts b/fixtures/local-mode-tests/tests/headers.test.ts deleted file mode 100644 index cd486b71b063..000000000000 --- a/fixtures/local-mode-tests/tests/headers.test.ts +++ /dev/null @@ -1,100 +0,0 @@ -import path from "path"; -import { describe, it, beforeAll, afterAll, expect } from "vitest"; -import { unstable_dev } from "wrangler"; -import type { UnstableDevWorker } from "wrangler"; - -describe("worker", () => { - let worker: UnstableDevWorker; - let resolveReadyPromise: (value: unknown) => void; - const readyPromise = new Promise((resolve) => { - resolveReadyPromise = resolve; - }); - - beforeAll(async () => { - worker = await unstable_dev( - path.resolve(__dirname, "..", "src", "headers.ts"), - { - experimental: { - disableExperimentalWarning: true, - disableDevRegistry: true, - }, - } - ); - - resolveReadyPromise(undefined); - }); - - afterAll(async () => { - await readyPromise; - await worker.stop(); - }); - - it.concurrent("should return Hi by default", async () => { - await readyPromise; - const resp = await worker.fetch("/"); - expect(resp).not.toBe(undefined); - if (resp) { - const respJson = await resp.text(); - expect(respJson).toBe(JSON.stringify({ greeting: "Hi!" })); - } - }); - it.concurrent("should return Bonjour when French", async () => { - await readyPromise; - const resp = await worker.fetch("/", { headers: { lang: "fr-FR" } }); - expect(resp).not.toBe(undefined); - if (resp) { - const respJson = await resp.text(); - expect(respJson).toBe(JSON.stringify({ greeting: "Bonjour!" })); - } - }); - - it.concurrent("should return G'day when Australian", async () => { - await readyPromise; - const resp = await worker.fetch("/", { headers: { lang: "en-AU" } }); - expect(resp).not.toBe(undefined); - if (resp) { - const respJson = await resp.text(); - expect(respJson).toBe(JSON.stringify({ greeting: "G'day!" })); - } - }); - - it.concurrent("should return Good day when British", async () => { - await readyPromise; - const resp = await worker.fetch("/", { headers: { lang: "en-GB" } }); - expect(resp).not.toBe(undefined); - if (resp) { - const respJson = await resp.text(); - expect(respJson).toBe(JSON.stringify({ greeting: "Good day!" })); - } - }); - - it.concurrent("should return Howdy when Texan", async () => { - await readyPromise; - const resp = await worker.fetch("/", { headers: { lang: "en-TX" } }); - expect(resp).not.toBe(undefined); - if (resp) { - const respJson = await resp.text(); - expect(respJson).toBe(JSON.stringify({ greeting: "Howdy!" })); - } - }); - - it.concurrent("should return Hello when American", async () => { - await readyPromise; - const resp = await worker.fetch("/", { headers: { lang: "en-US" } }); - expect(resp).not.toBe(undefined); - if (resp) { - const respJson = await resp.text(); - expect(respJson).toBe(JSON.stringify({ greeting: "Hello!" })); - } - }); - - it.concurrent("should return Hola when Spanish", async () => { - await readyPromise; - const resp = await worker.fetch("/", { headers: { lang: "es-ES" } }); - expect(resp).not.toBe(undefined); - if (resp) { - const respJson = await resp.text(); - expect(respJson).toBe(JSON.stringify({ greeting: "Hola!" })); - } - }); -}); diff --git a/fixtures/local-mode-tests/tests/module.test.ts b/fixtures/local-mode-tests/tests/module.test.ts index a12fdd332ce2..81f4c18977db 100644 --- a/fixtures/local-mode-tests/tests/module.test.ts +++ b/fixtures/local-mode-tests/tests/module.test.ts @@ -3,12 +3,8 @@ import { describe, it, beforeAll, afterAll, expect } from "vitest"; import { unstable_dev } from "wrangler"; import type { UnstableDevWorker } from "wrangler"; -describe("worker", () => { +describe("module worker", () => { let worker: UnstableDevWorker; - let resolveReadyPromise: (value: unknown) => void; - const readyPromise = new Promise((resolve) => { - resolveReadyPromise = resolve; - }); let originalNodeEnv: string | undefined; @@ -21,7 +17,7 @@ describe("worker", () => { worker = await unstable_dev( path.resolve(__dirname, "..", "src", "module.ts"), { - config: path.resolve(__dirname, "..", "src", "wrangler.module.toml"), + config: path.resolve(__dirname, "..", "wrangler.module.toml"), vars: { VAR4: "https://google.com" }, experimental: { disableExperimentalWarning: true, @@ -29,19 +25,19 @@ describe("worker", () => { }, } ); - - resolveReadyPromise(undefined); }); afterAll(async () => { - await readyPromise; - await worker.stop(); + try { + await worker.stop(); + } catch (e) { + console.error("Failed to stop worker", e); + } process.env.NODE_ENV = originalNodeEnv; }); - it.concurrent("renders", async () => { - await readyPromise; - const resp = await worker.fetch(); + it("renders variables", async () => { + const resp = await worker.fetch("/vars"); expect(resp).not.toBe(undefined); const text = await resp.text(); @@ -59,4 +55,74 @@ describe("worker", () => { }" `); }); + describe("header parsing", () => { + it.concurrent("should return Hi by default", async () => { + const resp = await worker.fetch("/"); + expect(resp).not.toBe(undefined); + const respJson = await resp.text(); + expect(respJson).toBe(JSON.stringify({ greeting: "Hi!" })); + }); + it.concurrent("should return Bonjour when French", async () => { + const resp = await worker.fetch("/", { headers: { lang: "fr-FR" } }); + expect(resp).not.toBe(undefined); + if (resp) { + const respJson = await resp.text(); + expect(respJson).toBe(JSON.stringify({ greeting: "Bonjour!" })); + } + }); + + it.concurrent("should return G'day when Australian", async () => { + const resp = await worker.fetch("/", { headers: { lang: "en-AU" } }); + expect(resp).not.toBe(undefined); + if (resp) { + const respJson = await resp.text(); + expect(respJson).toBe(JSON.stringify({ greeting: "G'day!" })); + } + }); + + it.concurrent("should return Good day when British", async () => { + const resp = await worker.fetch("/", { headers: { lang: "en-GB" } }); + expect(resp).not.toBe(undefined); + if (resp) { + const respJson = await resp.text(); + expect(respJson).toBe(JSON.stringify({ greeting: "Good day!" })); + } + }); + + it.concurrent("should return Howdy when Texan", async () => { + const resp = await worker.fetch("/", { headers: { lang: "en-TX" } }); + expect(resp).not.toBe(undefined); + if (resp) { + const respJson = await resp.text(); + expect(respJson).toBe(JSON.stringify({ greeting: "Howdy!" })); + } + }); + + it.concurrent("should return Hello when American", async () => { + const resp = await worker.fetch("/", { headers: { lang: "en-US" } }); + expect(resp).not.toBe(undefined); + if (resp) { + const respJson = await resp.text(); + expect(respJson).toBe(JSON.stringify({ greeting: "Hello!" })); + } + }); + + it.concurrent("should return Hola when Spanish", async () => { + const resp = await worker.fetch("/", { headers: { lang: "es-ES" } }); + expect(resp).not.toBe(undefined); + if (resp) { + const respJson = await resp.text(); + expect(respJson).toBe(JSON.stringify({ greeting: "Hola!" })); + } + }); + }); + describe("buffer import", () => { + it.concurrent("returns hex string", async () => { + const resp = await worker.fetch("/buffer"); + expect(resp).not.toBe(undefined); + + const text = await resp.text(); + expect(text).toMatch("68656c6c6f"); + }); + }); }); diff --git a/fixtures/local-mode-tests/tests/nodeBuiltinPackage.test.ts b/fixtures/local-mode-tests/tests/nodeBuiltinPackage.test.ts deleted file mode 100644 index c614c2d015b6..000000000000 --- a/fixtures/local-mode-tests/tests/nodeBuiltinPackage.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import path from "path"; -import { describe, it, beforeAll, afterAll, expect } from "vitest"; -import { unstable_dev } from "wrangler"; -import type { UnstableDevWorker } from "wrangler"; - -describe("worker", () => { - let worker: UnstableDevWorker; - let resolveReadyPromise: (value: unknown) => void; - const readyPromise = new Promise((resolve) => { - resolveReadyPromise = resolve; - }); - - beforeAll(async () => { - worker = await unstable_dev( - path.resolve(__dirname, "..", "src", "nodeBuiltinPackage.ts"), - { - experimental: { - disableExperimentalWarning: true, - disableDevRegistry: true, - }, - } - ); - - resolveReadyPromise(undefined); - }); - - afterAll(async () => { - await readyPromise; - await worker.stop(); - }); - - it.concurrent("returns hex string", async () => { - await readyPromise; - const resp = await worker.fetch(); - expect(resp).not.toBe(undefined); - - const text = await resp.text(); - expect(text).toMatch("68656c6c6f"); - }); -}); diff --git a/fixtures/local-mode-tests/tests/ports.test.ts b/fixtures/local-mode-tests/tests/ports.test.ts index 139650c2f958..5c13e5303884 100644 --- a/fixtures/local-mode-tests/tests/ports.test.ts +++ b/fixtures/local-mode-tests/tests/ports.test.ts @@ -3,80 +3,39 @@ import { describe, it, beforeAll, afterAll, expect } from "vitest"; import { unstable_dev } from "wrangler"; import type { UnstableDevWorker } from "wrangler"; -// Okay this test is seriously flaky, even without devRegistry enabled -// TODO: figure out why we can't run 8 wranglers at once -describe.skip("worker", () => { +describe("multiple workers", () => { let workers: UnstableDevWorker[]; - let resolveReadyPromise: (value: unknown) => void; - const readyPromise = new Promise((resolve) => { - resolveReadyPromise = resolve; - }); beforeAll(async () => { //since the script is invoked from the directory above, need to specify index.js is in src/ workers = await Promise.all([ - unstable_dev(path.resolve(__dirname, "..", "src", "basicModule.ts"), { - experimental: { - disableExperimentalWarning: true, - disableDevRegistry: true, - }, - }), - unstable_dev(path.resolve(__dirname, "..", "src", "basicModule.ts"), { - experimental: { - disableExperimentalWarning: true, - disableDevRegistry: true, - }, - }), - unstable_dev(path.resolve(__dirname, "..", "src", "basicModule.ts"), { - experimental: { - disableExperimentalWarning: true, - disableDevRegistry: true, - }, - }), - unstable_dev(path.resolve(__dirname, "..", "src", "basicModule.ts"), { - experimental: { - disableExperimentalWarning: true, - disableDevRegistry: true, - }, - }), - unstable_dev(path.resolve(__dirname, "..", "src", "basicModule.ts"), { + unstable_dev(path.resolve(__dirname, "..", "src", "module.ts"), { experimental: { disableExperimentalWarning: true, disableDevRegistry: true, }, }), - unstable_dev(path.resolve(__dirname, "..", "src", "basicModule.ts"), { + unstable_dev(path.resolve(__dirname, "..", "src", "module.ts"), { experimental: { disableExperimentalWarning: true, disableDevRegistry: true, }, }), - unstable_dev(path.resolve(__dirname, "..", "src", "basicModule.ts"), { - experimental: { - disableExperimentalWarning: true, - disableDevRegistry: true, - }, - }), - unstable_dev(path.resolve(__dirname, "..", "src", "basicModule.ts"), { + unstable_dev(path.resolve(__dirname, "..", "src", "module.ts"), { experimental: { disableExperimentalWarning: true, disableDevRegistry: true, }, }), ]); - - resolveReadyPromise(undefined); }); afterAll(async () => { - await readyPromise; await Promise.all(workers.map(async (worker) => await worker.stop())); }); - it.concurrent("should invoke the worker and exit", async () => { - await readyPromise; - + it.concurrent("all workers should be fetchable", async () => { const responses = await Promise.all( workers.map(async (worker) => await worker.fetch()) ); @@ -85,16 +44,11 @@ describe.skip("worker", () => { ); expect(parsedResponses).not.toBe(undefined); - expect(parsedResponses.length).toBe(8); + expect(parsedResponses.length).toBe(3); expect(parsedResponses).toEqual([ - "Hello World!", - "Hello World!", - "Hello World!", - "Hello World!", - "Hello World!", - "Hello World!", - "Hello World!", - "Hello World!", + '{"greeting":"Hi!"}', + '{"greeting":"Hi!"}', + '{"greeting":"Hi!"}', ]); }); }); diff --git a/fixtures/local-mode-tests/tests/sw.test.ts b/fixtures/local-mode-tests/tests/sw.test.ts index 255a892d76b3..4a6211a98001 100644 --- a/fixtures/local-mode-tests/tests/sw.test.ts +++ b/fixtures/local-mode-tests/tests/sw.test.ts @@ -3,12 +3,8 @@ import { describe, it, beforeAll, afterAll, expect } from "vitest"; import { unstable_dev } from "wrangler"; import type { UnstableDevWorker } from "wrangler"; -describe("worker", () => { +describe("service worker", () => { let worker: UnstableDevWorker; - let resolveReadyPromise: (value: unknown) => void; - const readyPromise = new Promise((resolve) => { - resolveReadyPromise = resolve; - }); let originalNodeEnv: string | undefined; @@ -19,24 +15,19 @@ describe("worker", () => { //since the script is invoked from the directory above, need to specify index.js is in src/ worker = await unstable_dev(path.resolve(__dirname, "..", "src", "sw.ts"), { - config: path.resolve(__dirname, "..", "src", "wrangler.sw.toml"), + config: path.resolve(__dirname, "..", "wrangler.sw.toml"), experimental: { disableExperimentalWarning: true, - disableDevRegistry: true, }, }); - - resolveReadyPromise(undefined); }); afterAll(async () => { - await readyPromise; await worker.stop(); process.env.NODE_ENV = originalNodeEnv; }); - it.concurrent("renders", async () => { - await readyPromise; + it("renders", async () => { const resp = await worker.fetch(); expect(resp).not.toBe(undefined); diff --git a/fixtures/local-mode-tests/tests/unstableDev.test.ts b/fixtures/local-mode-tests/tests/unstableDev.test.ts deleted file mode 100644 index 753d65c1d61c..000000000000 --- a/fixtures/local-mode-tests/tests/unstableDev.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -import path from "path"; -import { describe, it, beforeAll, afterAll, expect } from "vitest"; -import { unstable_dev } from "wrangler"; -import type { UnstableDevWorker } from "wrangler"; - -// TODO: add test for `experimentalLocal: true` once issue with dynamic -// `import()` and `npx-import` resolved: -// https://github.com/cloudflare/workers-sdk/pull/1940#issuecomment-1261166695 -describe("worker in local mode", () => { - let worker: UnstableDevWorker; - let resolveReadyPromise: (value: unknown) => void; - const readyPromise = new Promise((resolve) => { - resolveReadyPromise = resolve; - }); - - beforeAll(async () => { - //since the script is invoked from the directory above, need to specify index.js is in src/ - worker = await unstable_dev( - path.resolve(__dirname, "..", "src", "basicModule.ts"), - { - experimental: { - disableExperimentalWarning: true, - disableDevRegistry: true, - }, - } - ); - - resolveReadyPromise(undefined); - }); - - afterAll(async () => { - await readyPromise; - await worker.stop(); - }); - - it.concurrent("should invoke the worker and exit", async () => { - await readyPromise; - const resp = await worker.fetch(); - expect(resp).not.toBe(undefined); - if (resp) { - const text = await resp.text(); - - expect(text).toMatchInlineSnapshot(`"Hello World!"`); - } - }); -}); diff --git a/fixtures/local-mode-tests/vitest.config.ts b/fixtures/local-mode-tests/vitest.config.ts new file mode 100644 index 000000000000..b8effe20a4ed --- /dev/null +++ b/fixtures/local-mode-tests/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 20_000, + hookTimeout: 20_000, + teardownTimeout: 20_000, + useAtomics: true, + }, +}); diff --git a/fixtures/local-mode-tests/wrangler.d.ts b/fixtures/local-mode-tests/wrangler.d.ts deleted file mode 100644 index 00b095b414cc..000000000000 --- a/fixtures/local-mode-tests/wrangler.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module "wrangler"; diff --git a/fixtures/local-mode-tests/src/wrangler.module.toml b/fixtures/local-mode-tests/wrangler.module.toml similarity index 100% rename from fixtures/local-mode-tests/src/wrangler.module.toml rename to fixtures/local-mode-tests/wrangler.module.toml diff --git a/fixtures/local-mode-tests/src/wrangler.sw.toml b/fixtures/local-mode-tests/wrangler.sw.toml similarity index 71% rename from fixtures/local-mode-tests/src/wrangler.sw.toml rename to fixtures/local-mode-tests/wrangler.sw.toml index 4dc66bcd369a..c2135e4610e4 100644 --- a/fixtures/local-mode-tests/src/wrangler.sw.toml +++ b/fixtures/local-mode-tests/wrangler.sw.toml @@ -7,7 +7,7 @@ VAR2 = 123 VAR3 = {abc = "def"} [text_blobs] -TEXT = "../some-text.txt" +TEXT = "./src/some-text.txt" [data_blobs] -DATA = "../some-data.bin" +DATA = "./src/some-data.bin" diff --git a/fixtures/no-bundle-import/package.json b/fixtures/no-bundle-import/package.json index 8b18573366a9..23aa62a11b97 100644 --- a/fixtures/no-bundle-import/package.json +++ b/fixtures/no-bundle-import/package.json @@ -6,8 +6,7 @@ "deploy": "wrangler deploy", "start": "wrangler dev", "test": "vitest run", - "test:ci": "vitest run", - "test:watch": "npx vitest" + "test:watch": "vitest" }, "devDependencies": { "get-port": "^6.1.2", diff --git a/fixtures/no-bundle-import/vitest.config.ts b/fixtures/no-bundle-import/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/no-bundle-import/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/node-app-pages/package.json b/fixtures/node-app-pages/package.json index a99cec075cdc..7db2c6977c0c 100644 --- a/fixtures/node-app-pages/package.json +++ b/fixtures/node-app-pages/package.json @@ -7,9 +7,8 @@ "scripts": { "check:type": "tsc", "dev": "npx wrangler pages dev public --port 12345 --node-compat", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "dependencies": { diff --git a/fixtures/node-app-pages/vitest.config.ts b/fixtures/node-app-pages/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/node-app-pages/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/pages-d1-shim/package.json b/fixtures/pages-d1-shim/package.json index 08e02b8bf70b..42b3a79650b0 100644 --- a/fixtures/pages-d1-shim/package.json +++ b/fixtures/pages-d1-shim/package.json @@ -6,9 +6,8 @@ "scripts": { "check:type": "tsc", "dev": "npx wrangler pages dev ./public --d1 foobar --port 8777", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/pages-d1-shim/tsconfig.json b/fixtures/pages-d1-shim/tsconfig.json index 82e839806ab2..c6fdf652f6d1 100644 --- a/fixtures/pages-d1-shim/tsconfig.json +++ b/fixtures/pages-d1-shim/tsconfig.json @@ -6,7 +6,8 @@ "lib": ["ES2020"], "types": ["@cloudflare/workers-types"], "moduleResolution": "node", - "noEmit": true + "noEmit": true, + "skipLibCheck": true }, "include": ["**/*.ts"], "exclude": ["tests"] diff --git a/fixtures/pages-d1-shim/vitest.config.ts b/fixtures/pages-d1-shim/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/pages-d1-shim/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/pages-functions-app/package.json b/fixtures/pages-functions-app/package.json index b0b9e508f5d8..2c1886f05253 100644 --- a/fixtures/pages-functions-app/package.json +++ b/fixtures/pages-functions-app/package.json @@ -6,10 +6,9 @@ "main": "dist/worker.js", "scripts": { "check:type": "tsc", - "dev": "npx wrangler pages dev public --binding=NAME=VALUE --binding=OTHER_NAME=THING=WITH=EQUALS --r2=BUCKET --port 8789", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "dev": "wrangler pages dev public --binding=NAME=VALUE --binding=OTHER_NAME=THING=WITH=EQUALS --r2=BUCKET --port 8789", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/pages-functions-app/tsconfig.json b/fixtures/pages-functions-app/tsconfig.json index 45dd1c531231..397e76244c51 100644 --- a/fixtures/pages-functions-app/tsconfig.json +++ b/fixtures/pages-functions-app/tsconfig.json @@ -6,6 +6,7 @@ "lib": ["ES2020"], "types": ["@cloudflare/workers-types"], "moduleResolution": "node", - "noEmit": true + "noEmit": true, + "skipLibCheck": true } } diff --git a/fixtures/pages-functions-app/vitest.config.ts b/fixtures/pages-functions-app/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/pages-functions-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/pages-functions-wasm-app/package.json b/fixtures/pages-functions-wasm-app/package.json index 9ba18729c664..61ded0a6cf86 100644 --- a/fixtures/pages-functions-wasm-app/package.json +++ b/fixtures/pages-functions-wasm-app/package.json @@ -7,9 +7,8 @@ "check:type": "tsc", "dev": "npx wrangler pages dev public --port 8776", "publish": "npx wrangler pages deploy public", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/pages-functions-wasm-app/tsconfig.json b/fixtures/pages-functions-wasm-app/tsconfig.json index 6eb14e3584b7..874dec6ac33a 100644 --- a/fixtures/pages-functions-wasm-app/tsconfig.json +++ b/fixtures/pages-functions-wasm-app/tsconfig.json @@ -6,7 +6,8 @@ "lib": ["ES2020"], "types": ["node"], "moduleResolution": "node", - "noEmit": true + "noEmit": true, + "skipLibCheck": true }, "include": ["tests", "../../node-types.d.ts"] } diff --git a/fixtures/pages-functions-wasm-app/vitest.config.ts b/fixtures/pages-functions-wasm-app/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/pages-functions-wasm-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/pages-functions-with-routes-app/package.json b/fixtures/pages-functions-with-routes-app/package.json index 31baa6f26a7c..b03c8c7d9021 100644 --- a/fixtures/pages-functions-with-routes-app/package.json +++ b/fixtures/pages-functions-with-routes-app/package.json @@ -6,9 +6,8 @@ "scripts": { "check:type": "tsc", "dev": "npx wrangler pages dev public --port 8776", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/pages-functions-with-routes-app/vitest.config.ts b/fixtures/pages-functions-with-routes-app/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/pages-functions-with-routes-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/pages-plugin-example/turbo.json b/fixtures/pages-plugin-example/turbo.json new file mode 100644 index 000000000000..1a6c74c9def8 --- /dev/null +++ b/fixtures/pages-plugin-example/turbo.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://turbo.build/schema.json", + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["dist/**"] + } + } +} diff --git a/fixtures/pages-plugin-mounted-on-root-app/package.json b/fixtures/pages-plugin-mounted-on-root-app/package.json index 6922c7887235..f017a50d4e5a 100644 --- a/fixtures/pages-plugin-mounted-on-root-app/package.json +++ b/fixtures/pages-plugin-mounted-on-root-app/package.json @@ -6,10 +6,9 @@ "main": "dist/worker.js", "scripts": { "check:type": "tsc", - "dev": "npx wrangler pages dev public --port 8793", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "dev": "wrangler pages dev public --port 8793", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/pages-plugin-mounted-on-root-app/vitest.config.ts b/fixtures/pages-plugin-mounted-on-root-app/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/pages-plugin-mounted-on-root-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/pages-simple-assets/package.json b/fixtures/pages-simple-assets/package.json index 2cfddd9e27cc..89418e261950 100644 --- a/fixtures/pages-simple-assets/package.json +++ b/fixtures/pages-simple-assets/package.json @@ -7,9 +7,8 @@ "scripts": { "check:type": "tsc", "dev": "npx wrangler pages dev public", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/pages-simple-assets/vitest.config.ts b/fixtures/pages-simple-assets/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/pages-simple-assets/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/pages-workerjs-and-functions-app/package.json b/fixtures/pages-workerjs-and-functions-app/package.json index b016c8a1c7cc..3639dca218d8 100644 --- a/fixtures/pages-workerjs-and-functions-app/package.json +++ b/fixtures/pages-workerjs-and-functions-app/package.json @@ -6,9 +6,8 @@ "scripts": { "check:type": "tsc", "dev": "npx wrangler pages dev public --port 8955", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/pages-workerjs-and-functions-app/vitest.config.ts b/fixtures/pages-workerjs-and-functions-app/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/pages-workerjs-and-functions-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/pages-workerjs-app/package.json b/fixtures/pages-workerjs-app/package.json index a06ddabb2824..8f7e4660041a 100644 --- a/fixtures/pages-workerjs-app/package.json +++ b/fixtures/pages-workerjs-app/package.json @@ -6,9 +6,8 @@ "scripts": { "check:type": "tsc", "dev": "npx wrangler pages dev ./workerjs-test --port 8792", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/pages-workerjs-app/tsconfig.json b/fixtures/pages-workerjs-app/tsconfig.json index 6eb14e3584b7..874dec6ac33a 100644 --- a/fixtures/pages-workerjs-app/tsconfig.json +++ b/fixtures/pages-workerjs-app/tsconfig.json @@ -6,7 +6,8 @@ "lib": ["ES2020"], "types": ["node"], "moduleResolution": "node", - "noEmit": true + "noEmit": true, + "skipLibCheck": true }, "include": ["tests", "../../node-types.d.ts"] } diff --git a/fixtures/pages-workerjs-app/vitest.config.ts b/fixtures/pages-workerjs-app/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/pages-workerjs-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/pages-workerjs-directory/package.json b/fixtures/pages-workerjs-directory/package.json index c2b153a90741..1d89ffafbf9d 100644 --- a/fixtures/pages-workerjs-directory/package.json +++ b/fixtures/pages-workerjs-directory/package.json @@ -6,8 +6,7 @@ "scripts": { "check:type": "tsc", "dev": "npx wrangler pages dev public --d1=D1 --d1=PUT=elsewhere --kv KV --kv KV_REF=other_kv --r2 R2 --r2=R2_REF=other_r2 --port 8794", - "test": "npx vitest run", - "test:ci": "npx vitest run", + "test": "vitest run", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/pages-workerjs-directory/tsconfig.json b/fixtures/pages-workerjs-directory/tsconfig.json index 6eb14e3584b7..874dec6ac33a 100644 --- a/fixtures/pages-workerjs-directory/tsconfig.json +++ b/fixtures/pages-workerjs-directory/tsconfig.json @@ -6,7 +6,8 @@ "lib": ["ES2020"], "types": ["node"], "moduleResolution": "node", - "noEmit": true + "noEmit": true, + "skipLibCheck": true }, "include": ["tests", "../../node-types.d.ts"] } diff --git a/fixtures/pages-workerjs-directory/vitest.config.ts b/fixtures/pages-workerjs-directory/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/pages-workerjs-directory/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/pages-workerjs-wasm-app/package.json b/fixtures/pages-workerjs-wasm-app/package.json index 93dc4cb8c642..a4b912abf097 100644 --- a/fixtures/pages-workerjs-wasm-app/package.json +++ b/fixtures/pages-workerjs-wasm-app/package.json @@ -7,9 +7,8 @@ "check:type": "tsc", "dev": "npx wrangler pages dev public --port 8776", "publish": "npx wrangler pages deploy public", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/pages-workerjs-wasm-app/tsconfig.json b/fixtures/pages-workerjs-wasm-app/tsconfig.json index 6eb14e3584b7..874dec6ac33a 100644 --- a/fixtures/pages-workerjs-wasm-app/tsconfig.json +++ b/fixtures/pages-workerjs-wasm-app/tsconfig.json @@ -6,7 +6,8 @@ "lib": ["ES2020"], "types": ["node"], "moduleResolution": "node", - "noEmit": true + "noEmit": true, + "skipLibCheck": true }, "include": ["tests", "../../node-types.d.ts"] } diff --git a/fixtures/pages-workerjs-wasm-app/vitest.config.ts b/fixtures/pages-workerjs-wasm-app/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/pages-workerjs-wasm-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/pages-workerjs-with-routes-app/package.json b/fixtures/pages-workerjs-with-routes-app/package.json index 20a2f43be483..2b5dbec493d7 100644 --- a/fixtures/pages-workerjs-with-routes-app/package.json +++ b/fixtures/pages-workerjs-with-routes-app/package.json @@ -6,9 +6,8 @@ "scripts": { "check:type": "tsc", "dev": "npx wrangler pages dev public --port 8751", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/pages-workerjs-with-routes-app/tsconfig.json b/fixtures/pages-workerjs-with-routes-app/tsconfig.json index 6eb14e3584b7..874dec6ac33a 100644 --- a/fixtures/pages-workerjs-with-routes-app/tsconfig.json +++ b/fixtures/pages-workerjs-with-routes-app/tsconfig.json @@ -6,7 +6,8 @@ "lib": ["ES2020"], "types": ["node"], "moduleResolution": "node", - "noEmit": true + "noEmit": true, + "skipLibCheck": true }, "include": ["tests", "../../node-types.d.ts"] } diff --git a/fixtures/pages-workerjs-with-routes-app/vitest.config.ts b/fixtures/pages-workerjs-with-routes-app/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/pages-workerjs-with-routes-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/pages-ws-app/package.json b/fixtures/pages-ws-app/package.json index c1f36b3949fe..ec5183834cf9 100644 --- a/fixtures/pages-ws-app/package.json +++ b/fixtures/pages-ws-app/package.json @@ -9,9 +9,8 @@ "check:type": "tsc", "dev": "npx wrangler pages dev --port 8790 --proxy 8791 -- pnpm run server", "server": "node dist/index.js", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/pages-ws-app/turbo.json b/fixtures/pages-ws-app/turbo.json new file mode 100644 index 000000000000..1a6c74c9def8 --- /dev/null +++ b/fixtures/pages-ws-app/turbo.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://turbo.build/schema.json", + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["dist/**"] + } + } +} diff --git a/fixtures/pages-ws-app/vitest.config.ts b/fixtures/pages-ws-app/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/pages-ws-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/remix-pages-app/package.json b/fixtures/remix-pages-app/package.json index e173e463de3c..ef9532c36461 100644 --- a/fixtures/remix-pages-app/package.json +++ b/fixtures/remix-pages-app/package.json @@ -10,9 +10,8 @@ "dev": "remix build && run-p \"dev:*\"", "start": "cross-env NODE_ENV=production pnpm run dev:wrangler", "check:type": "tsc", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "@remix-run/cloudflare-pages": "^1.17.0", diff --git a/fixtures/remix-pages-app/turbo.json b/fixtures/remix-pages-app/turbo.json new file mode 100644 index 000000000000..b65133334733 --- /dev/null +++ b/fixtures/remix-pages-app/turbo.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://turbo.build/schema.json", + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["public/**"] + } + } +} diff --git a/fixtures/remix-pages-app/vitest.config.ts b/fixtures/remix-pages-app/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/remix-pages-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/service-bindings-app/package.json b/fixtures/service-bindings-app/package.json index 82013ae2525c..d50e59931348 100644 --- a/fixtures/service-bindings-app/package.json +++ b/fixtures/service-bindings-app/package.json @@ -5,9 +5,8 @@ "scripts": { "check:type": "tsc", "dev": "npx concurrently -s first -k \"wrangler dev a/index.ts --local --port 8300\" \"wrangler dev b/index.ts --local --port 8301\"", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/service-bindings-app/tests/index.test.ts b/fixtures/service-bindings-app/tests/index.test.ts index c09f0840a736..ca66bdd28d1b 100644 --- a/fixtures/service-bindings-app/tests/index.test.ts +++ b/fixtures/service-bindings-app/tests/index.test.ts @@ -1,16 +1,17 @@ import { describe, expect, it, beforeAll, afterAll } from "vitest"; import { UnstableDevWorker, unstable_dev } from "wrangler"; +import path from "node:path"; describe("Service Bindings", () => { let aWorker: UnstableDevWorker; let bWorker: UnstableDevWorker; beforeAll(async () => { - bWorker = await unstable_dev("./b/index.ts", { - config: "./b/wrangler.toml", + bWorker = await unstable_dev(path.join(__dirname, "../b/index.ts"), { + config: path.join(__dirname, "../b/wrangler.toml"), }); - aWorker = await unstable_dev("./a/index.ts", { - config: "./a/wrangler.toml", + aWorker = await unstable_dev(path.join(__dirname, "../a/index.ts"), { + config: path.join(__dirname, "../a/wrangler.toml"), }); // Service registry is polled every 300ms, // so let's give worker A some time to find B diff --git a/fixtures/service-bindings-app/tsconfig.json b/fixtures/service-bindings-app/tsconfig.json index bc2585c9fd45..856398634a5e 100644 --- a/fixtures/service-bindings-app/tsconfig.json +++ b/fixtures/service-bindings-app/tsconfig.json @@ -5,7 +5,8 @@ "lib": ["ES2020"], "types": ["@cloudflare/workers-types"], "moduleResolution": "node", - "noEmit": true + "noEmit": true, + "skipLibCheck": true }, "include": ["**/*.ts"], "exclude": ["tests"] diff --git a/fixtures/service-bindings-app/vitest.config.ts b/fixtures/service-bindings-app/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/service-bindings-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/fixtures/shared/src/run-wrangler-long-lived.ts b/fixtures/shared/src/run-wrangler-long-lived.ts index fd3b38616002..620d3e4022bb 100644 --- a/fixtures/shared/src/run-wrangler-long-lived.ts +++ b/fixtures/shared/src/run-wrangler-long-lived.ts @@ -55,8 +55,12 @@ async function runLongLivedWrangler(command: string[], cwd: string) { }); const chunks: Buffer[] = []; - wranglerProcess.stdout?.on("data", (chunk) => chunks.push(chunk)); - wranglerProcess.stderr?.on("data", (chunk) => chunks.push(chunk)); + wranglerProcess.stdout?.on("data", (chunk) => { + chunks.push(chunk); + }); + wranglerProcess.stderr?.on("data", (chunk) => { + chunks.push(chunk); + }); const getOutput = () => Buffer.concat(chunks).toString(); const timeoutHandle = setTimeout(() => { diff --git a/fixtures/worker-app/package.json b/fixtures/worker-app/package.json index 6ea49b802588..ed7da5225993 100644 --- a/fixtures/worker-app/package.json +++ b/fixtures/worker-app/package.json @@ -8,9 +8,8 @@ "main": "src/index.js", "scripts": { "check:type": "tsc", - "test": "npx vitest run", - "test:ci": "npx vitest run", - "test:watch": "npx vitest", + "test": "vitest run", + "test:watch": "vitest", "type:tests": "tsc -p ./tests/tsconfig.json" }, "devDependencies": { diff --git a/fixtures/worker-app/tsconfig.json b/fixtures/worker-app/tsconfig.json index 6eb14e3584b7..b901134e4e79 100644 --- a/fixtures/worker-app/tsconfig.json +++ b/fixtures/worker-app/tsconfig.json @@ -5,6 +5,7 @@ "module": "CommonJS", "lib": ["ES2020"], "types": ["node"], + "skipLibCheck": true, "moduleResolution": "node", "noEmit": true }, diff --git a/fixtures/worker-app/vitest.config.ts b/fixtures/worker-app/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/fixtures/worker-app/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/package.json b/package.json index 5747d7770d95..298993cf8b1e 100644 --- a/package.json +++ b/package.json @@ -13,14 +13,13 @@ "build": "dotenv -- turbo build", "check": "dotenv -- turbo check:lint check:type check:format type:tests", "check:format": "prettier . --check --ignore-unknown", - "check:lint": "dotenv -- turbo check:lint", + "check:lint": "node ensure-turbo-build-output.mjs && dotenv -- turbo check:lint", "check:type": "dotenv -- turbo check:type type:tests", "dev": "dotenv -- turbo dev", "fix": "pnpm run prettify && dotenv -- turbo check:lint -- --fix", "prettify": "prettier . --write --ignore-unknown", - "test": "dotenv -- turbo test --concurrency=1", - "test:ci": "dotenv -- turbo test:ci --filter=!local-mode-tests --filter=!playground-preview-worker --filter=!no-bundle-import --filter=!pages-functions-app --filter=!pages-plugin-mounted-on-root-app --filter=!workers.new --concurrency=1", - "test:ci:quarantine": "dotenv -- turbo test:ci --filter=local-mode-tests --filter=pages-functions-app --filter=pages-plugin-mounted-on-root-app --filter=playground-preview-worker --filter=no-bundle-import --filter=workers.new --concurrency=1", + "test": "dotenv -- turbo test", + "test:ci": "vitest run && dotenv -- turbo test:ci --filter=wrangler --filter=miniflare", "test:watch": "turbo test:watch", "type:tests": "dotenv -- turbo type:tests", "gen:package": "turbo gen package" @@ -38,7 +37,7 @@ "rimraf": "^5.0.1", "typescript": "^4.8.4", "vite": "^4.0.4", - "vitest": "^0.31.1" + "vitest": "^0.34.6" }, "devDependencies": { "@cloudflare/workers-types": "^4.20230821.0", diff --git a/packages/cli/__tests__/cli.test.ts b/packages/cli/__tests__/cli.test.ts index e7aaec5793ac..7138c2837e82 100644 --- a/packages/cli/__tests__/cli.test.ts +++ b/packages/cli/__tests__/cli.test.ts @@ -3,6 +3,8 @@ import { space } from ".."; describe("cli", () => { test("test spaces", () => { - expect(space(300)).toHaveLength(300); + expect(space(300)).toMatchInlineSnapshot( + '"                                                                                                                                                                                                                                                                                                            "' + ); }); }); diff --git a/packages/cli/package.json b/packages/cli/package.json index 8283468a69eb..d51b2b0e6f06 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -12,7 +12,6 @@ "scripts": { "check:type": "tsc", "test": "vitest run", - "test:ci": "vitest run", "check:lint": "eslint ." }, "repository": { diff --git a/packages/cli/vite.setup.ts b/packages/cli/vite.setup.ts index 8df54aedbd59..747cef66e1b6 100644 --- a/packages/cli/vite.setup.ts +++ b/packages/cli/vite.setup.ts @@ -1,3 +1,6 @@ +import chalk from "chalk"; import { vi } from "vitest"; vi.mock("log-update"); + +chalk.level = 0; diff --git a/packages/cli/vite.config.ts b/packages/cli/vitest.config.ts similarity index 100% rename from packages/cli/vite.config.ts rename to packages/cli/vitest.config.ts diff --git a/packages/create-cloudflare/package.json b/packages/create-cloudflare/package.json index f48f7c779d54..3ee9d336127e 100644 --- a/packages/create-cloudflare/package.json +++ b/packages/create-cloudflare/package.json @@ -38,7 +38,8 @@ "test:e2e:yarn": "pnpm run build && cross-env TEST_PM=yarn vitest run --config ./vitest-e2e.config.ts", "test:unit": "vitest run --config ./vitest.config.ts", "test:unit:watch": "vitest --config ./vitest.config.ts", - "watch": "node -r esbuild-register scripts/build.ts --watch" + "watch": "node -r esbuild-register scripts/build.ts --watch", + "test:ci": "vitest run --config ./vitest.config.ts" }, "devDependencies": { "@babel/parser": "^7.21.3", @@ -75,7 +76,6 @@ "typescript": "^5.0.2", "undici": "5.20.0", "vite-tsconfig-paths": "^4.0.8", - "vitest": "^0.30.0", "which-pm-runs": "^1.1.0", "wrangler": "workspace:*", "yargs": "^17.7.1", diff --git a/packages/create-cloudflare/turbo.json b/packages/create-cloudflare/turbo.json index f0b50391ed8b..53898ea8d815 100644 --- a/packages/create-cloudflare/turbo.json +++ b/packages/create-cloudflare/turbo.json @@ -4,7 +4,8 @@ "pipeline": { "build": { - "env": ["VITEST", "TEST_PM", "npm_config_user_agent", "CI"] + "env": ["VITEST", "TEST_PM", "npm_config_user_agent", "CI"], + "outputs": ["dist/**"] }, "test:e2e:*": { "env": [ diff --git a/packages/create-cloudflare/vitest.d.ts b/packages/create-cloudflare/vitest.d.ts index 0123992f7727..60f43dd1217d 100644 --- a/packages/create-cloudflare/vitest.d.ts +++ b/packages/create-cloudflare/vitest.d.ts @@ -1,12 +1,14 @@ +// See https://vitest.dev/guide/extending-matchers.html +/* eslint-disable unused-imports/no-unused-imports */ +/* eslint-disable no-shadow */ +/* eslint-disable @typescript-eslint/no-empty-interface */ +import 'vitest' + interface CustomMatchers { toExist(): R; } -declare namespace Vi { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface Assertion extends CustomMatchers {} - // eslint-disable-next-line @typescript-eslint/no-empty-interface +declare module 'vitest' { + interface Assertion extends CustomMatchers {} interface AsymmetricMatchersContaining extends CustomMatchers {} - - // Note: augmenting jest.Matchers interface will also work. } diff --git a/packages/edge-preview-authenticated-proxy/package.json b/packages/edge-preview-authenticated-proxy/package.json index 390349e55b1c..17ed4eb0a93e 100644 --- a/packages/edge-preview-authenticated-proxy/package.json +++ b/packages/edge-preview-authenticated-proxy/package.json @@ -7,7 +7,7 @@ "publish": "wrangler deploy", "start": "wrangler dev", "test": "vitest run", - "test:ci": "vitest run", + "type:tests": "tsc -p ./tests/tsconfig.json", "check:type": "tsc" }, @@ -16,7 +16,6 @@ "@cloudflare/workers-types": "^4.20230321.0", "cookie": "^0.5.0", "toucan-js": "^3.1.0", - "vitest": "^0.31.0", "wrangler": "workspace:*", "@types/cookie": "^0.5.1" } diff --git a/packages/edge-preview-authenticated-proxy/tests/index.test.ts b/packages/edge-preview-authenticated-proxy/tests/index.test.ts index a3f2590ed58b..a2894af5b173 100644 --- a/packages/edge-preview-authenticated-proxy/tests/index.test.ts +++ b/packages/edge-preview-authenticated-proxy/tests/index.test.ts @@ -1,7 +1,7 @@ import { randomBytes } from "crypto"; import fs from "fs/promises"; import os from "os"; -import path, { resolve } from "path"; +import path from "path"; import { describe, expect, it, beforeAll, afterAll } from "vitest"; import { unstable_dev } from "wrangler"; import type { UnstableDevWorker } from "wrangler"; @@ -19,10 +19,10 @@ describe("Preview Worker", () => { let tmpDir: string; beforeAll(async () => { - worker = await unstable_dev(resolve(__dirname, "../src/index.ts"), { + worker = await unstable_dev(path.join(__dirname, "../src/index.ts"), { + config: path.join(__dirname, "../wrangler.toml"), experimental: { disableExperimentalWarning: true, - // experimentalLocal: true, }, }); @@ -63,7 +63,16 @@ describe("Preview Worker", () => { `.trim() ); + await fs.writeFile( + path.join(tmpDir, "wrangler.toml"), + /*toml*/ ` +name = "remote-worker" +compatibility_date = "2023-01-01" + `.trim() + ); + remote = await unstable_dev(path.join(tmpDir, "remote.js"), { + config: path.join(tmpDir, "wrangler.toml"), experimental: { disableExperimentalWarning: true }, port: 6756, }); @@ -145,9 +154,7 @@ describe("Preview Worker", () => { expect( json.headers.find(([h]: [string]) => h === "cf-workers-preview-token")[1] ).toBe(token); - expect(json.url).toMatchInlineSnapshot( - '"http://preview.devprod.cloudflare.dev/"' - ); + expect(json.url).toMatchInlineSnapshot('"http://127.0.0.1:6756/"'); }); it("should be redirected with cookie", async () => { const resp = await worker.fetch( @@ -189,9 +196,7 @@ describe("Preview Worker", () => { expect(Object.fromEntries([...json.headers])).toMatchObject({ "cf-workers-preview-token": "TEST_TOKEN", }); - expect(json.url).toMatchInlineSnapshot( - '"http://preview.devprod.cloudflare.dev/"' - ); + expect(json.url).toMatchInlineSnapshot('"http://127.0.0.1:6756/"'); }); it("should not follow redirects", async () => { const resp = await worker.fetch( @@ -207,7 +212,7 @@ describe("Preview Worker", () => { expect(resp.status).toMatchInlineSnapshot("302"); expect(resp.headers.get("Location")).toMatchInlineSnapshot( - '"https://example.com/"' + '"https://example.com"' ); expect(await resp.text()).toMatchInlineSnapshot('""'); }); @@ -260,7 +265,7 @@ describe("Raw HTTP preview", () => { let worker: UnstableDevWorker; beforeAll(async () => { - worker = await unstable_dev(resolve(__dirname, "../src/index.ts"), { + worker = await unstable_dev(path.join(__dirname, "../src/index.ts"), { // @ts-expect-error TODO: figure out the right way to get the server to accept host from the request host: "0000.rawhttp.devprod.cloudflare.dev", experimental: { diff --git a/packages/format-errors/turbo.json b/packages/format-errors/turbo.json new file mode 100644 index 000000000000..1a6c74c9def8 --- /dev/null +++ b/packages/format-errors/turbo.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://turbo.build/schema.json", + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["dist/**"] + } + } +} diff --git a/packages/miniflare/turbo.json b/packages/miniflare/turbo.json index 1a6c74c9def8..89a21f87cfb8 100644 --- a/packages/miniflare/turbo.json +++ b/packages/miniflare/turbo.json @@ -3,7 +3,10 @@ "extends": ["//"], "pipeline": { "build": { - "outputs": ["dist/**"] + "outputs": ["dist/**"], + "env": [ + "CI_OS" + ] } } } diff --git a/packages/pages-shared/vite.config.ts b/packages/pages-shared/vitest.config.ts similarity index 100% rename from packages/pages-shared/vite.config.ts rename to packages/pages-shared/vitest.config.ts diff --git a/packages/playground-preview-worker/package.json b/packages/playground-preview-worker/package.json index eb5211f33e48..978517fb4a02 100644 --- a/packages/playground-preview-worker/package.json +++ b/packages/playground-preview-worker/package.json @@ -23,7 +23,6 @@ "itty-router": "^4.0.13", "toucan-js": "^3.2.2", "undici": "^5.23.0", - "vitest": "^0.31.4", "wrangler": "^3.5.1" } } diff --git a/packages/prerelease-registry/turbo.json b/packages/prerelease-registry/turbo.json new file mode 100644 index 000000000000..1a6c74c9def8 --- /dev/null +++ b/packages/prerelease-registry/turbo.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://turbo.build/schema.json", + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["dist/**"] + } + } +} diff --git a/packages/workers-playground/turbo.json b/packages/workers-playground/turbo.json new file mode 100644 index 000000000000..1a6c74c9def8 --- /dev/null +++ b/packages/workers-playground/turbo.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://turbo.build/schema.json", + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["dist/**"] + } + } +} diff --git a/packages/workers.new/tsconfig.json b/packages/workers.new/tsconfig.json index 15efd90bfd82..5657a03d570c 100644 --- a/packages/workers.new/tsconfig.json +++ b/packages/workers.new/tsconfig.json @@ -1,5 +1,4 @@ { - "extends": "@cloudflare/workers-tsconfig/tsconfig.json", "compilerOptions": { "strict": true, "alwaysStrict": true, @@ -12,6 +11,5 @@ "lib": ["es2020"], "noEmit": true }, - "include": ["src"], - "exclude": ["node_modules"] + "exclude": ["tests/**"] } diff --git a/packages/workers.new/vitest.config.ts b/packages/workers.new/vitest.config.ts new file mode 100644 index 000000000000..ed02453b1c87 --- /dev/null +++ b/packages/workers.new/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + testTimeout: 10_000, + hookTimeout: 10_000, + teardownTimeout: 10_000, + useAtomics: true, + }, +}); diff --git a/packages/wrangler/package.json b/packages/wrangler/package.json index 44763415dece..b370e166f847 100644 --- a/packages/wrangler/package.json +++ b/packages/wrangler/package.json @@ -198,7 +198,6 @@ "ts-dedent": "^2.2.0", "undici": "5.20.0", "update-check": "^1.5.4", - "vitest": "^0.34.4", "ws": "^8.5.0", "xdg-app-paths": "^8.3.0", "yargs": "^17.7.2", diff --git a/packages/wrangler/src/__tests__/deploy.test.ts b/packages/wrangler/src/__tests__/deploy.test.ts index 655910e8789d..ecc8254e8e8c 100644 --- a/packages/wrangler/src/__tests__/deploy.test.ts +++ b/packages/wrangler/src/__tests__/deploy.test.ts @@ -31,6 +31,8 @@ import { mockGetMemberships, mockOAuthFlow, } from "./helpers/mock-oauth-flow"; +import { mockUploadWorkerRequest } from "./helpers/mock-upload-worker"; +import { mockSubDomainRequest } from "./helpers/mock-workers-subdomain"; import { createFetchResult, msw, @@ -48,11 +50,9 @@ import writeWranglerToml from "./helpers/write-wrangler-toml"; import type { Config } from "../config"; import type { CustomDomain, CustomDomainChangeset } from "../deploy/deploy"; -import type { WorkerMetadata } from "../deployment-bundle/create-worker-upload-form"; -import type { CfWorkerInit } from "../deployment-bundle/worker"; import type { KVNamespaceInfo } from "../kv/helpers"; import type { PutConsumerBody } from "../queues/client"; -import type { ResponseComposition, RestContext, RestRequest } from "msw"; +import type { RestRequest } from "msw"; describe("deploy", () => { mockAccountId(); @@ -8740,173 +8740,6 @@ function mockLastDeploymentRequest() { msw.use(...mswSuccessDeploymentScriptMetadata); } -/** Create a mock handler for the request to upload a worker script. */ -export function mockUploadWorkerRequest( - options: { - available_on_subdomain?: boolean; - expectedEntry?: string | RegExp; - expectedMainModule?: string; - expectedType?: "esm" | "sw"; - expectedBindings?: unknown; - expectedModules?: Record; - expectedCompatibilityDate?: string; - expectedCompatibilityFlags?: string[]; - expectedMigrations?: CfWorkerInit["migrations"]; - expectedTailConsumers?: CfWorkerInit["tail_consumers"]; - expectedUnsafeMetaData?: Record; - expectedCapnpSchema?: string; - expectedLimits?: CfWorkerInit["limits"]; - env?: string; - legacyEnv?: boolean; - keepVars?: boolean; - tag?: string; - } = {} -) { - const { - available_on_subdomain = true, - expectedEntry, - expectedMainModule = "index.js", - expectedType = "esm", - expectedBindings, - expectedModules = {}, - expectedCompatibilityDate, - expectedCompatibilityFlags, - env = undefined, - legacyEnv = false, - expectedMigrations, - expectedTailConsumers, - expectedUnsafeMetaData, - expectedCapnpSchema, - expectedLimits, - keepVars, - } = options; - if (env && !legacyEnv) { - msw.use( - rest.put( - "*/accounts/:accountId/workers/services/:scriptName/environments/:envName", - handleUpload - ) - ); - } else { - msw.use( - rest.put( - "*/accounts/:accountId/workers/scripts/:scriptName", - handleUpload - ) - ); - } - - async function handleUpload( - req: RestRequest, - res: ResponseComposition, - ctx: RestContext - ) { - expect(req.params.accountId).toEqual("some-account-id"); - expect(req.params.scriptName).toEqual( - legacyEnv && env ? `test-name-${env}` : "test-name" - ); - if (!legacyEnv) { - expect(req.params.envName).toEqual(env); - } - expect(req.url.searchParams.get("include_subdomain_availability")).toEqual( - "true" - ); - expect(req.url.searchParams.get("excludeScript")).toEqual("true"); - - const formBody = await ( - req as MockedRequest as RestRequestWithFormData - ).formData(); - if (expectedEntry !== undefined) { - expect(formBody.get("index.js")).toMatch(expectedEntry); - } - const metadata = JSON.parse( - formBody.get("metadata") as string - ) as WorkerMetadata; - if (expectedType === "esm") { - expect(metadata.main_module).toEqual(expectedMainModule); - } else { - expect(metadata.body_part).toEqual("index.js"); - } - - if (keepVars) { - expect(metadata.keep_bindings).toEqual(["plain_text", "json"]); - } else { - expect(metadata.keep_bindings).toBeFalsy(); - } - - if ("expectedBindings" in options) { - expect(metadata.bindings).toEqual(expectedBindings); - } - if ("expectedCompatibilityDate" in options) { - expect(metadata.compatibility_date).toEqual(expectedCompatibilityDate); - } - if ("expectedCompatibilityFlags" in options) { - expect(metadata.compatibility_flags).toEqual(expectedCompatibilityFlags); - } - if ("expectedMigrations" in options) { - expect(metadata.migrations).toEqual(expectedMigrations); - } - if ("expectedTailConsumers" in options) { - expect(metadata.tail_consumers).toEqual(expectedTailConsumers); - } - if ("expectedCapnpSchema" in options) { - expect(formBody.get(metadata.capnp_schema ?? "")).toEqual( - expectedCapnpSchema - ); - } - if ("expectedLimits" in options) { - expect(metadata.limits).toEqual(expectedLimits); - } - if (expectedUnsafeMetaData !== undefined) { - Object.keys(expectedUnsafeMetaData).forEach((key) => { - expect(metadata[key]).toEqual(expectedUnsafeMetaData[key]); - }); - } - for (const [name, content] of Object.entries(expectedModules)) { - expect(formBody.get(name)).toEqual(content); - } - - return res( - ctx.json( - createFetchResult({ - available_on_subdomain, - id: "abc12345", - etag: "etag98765", - pipeline_hash: "hash9999", - mutable_pipeline_id: "mutableId", - tag: "sample-tag", - deployment_id: "Galaxy-Class", - }) - ) - ); - } -} - -/** Create a mock handler for the request to get the account's subdomain. */ -export function mockSubDomainRequest( - subdomain = "test-sub-domain", - registeredWorkersDev = true -) { - if (registeredWorkersDev) { - msw.use( - rest.get("*/accounts/:accountId/workers/subdomain", (req, res, ctx) => { - return res.once(ctx.json(createFetchResult({ subdomain }))); - }) - ); - } else { - msw.use( - rest.get("*/accounts/:accountId/workers/subdomain", (req, res, ctx) => { - return res.once( - ctx.json( - createFetchResult(null, false, [ - { code: 10007, message: "haven't registered workers.dev" }, - ]) - ) - ); - }) - ); - } -} // // // diff --git a/packages/wrangler/src/__tests__/helpers/mock-upload-worker.ts b/packages/wrangler/src/__tests__/helpers/mock-upload-worker.ts new file mode 100644 index 000000000000..85e67b0ca92d --- /dev/null +++ b/packages/wrangler/src/__tests__/helpers/mock-upload-worker.ts @@ -0,0 +1,193 @@ +import { Blob } from "node:buffer"; +import { MockedRequest, rest } from "msw"; +import { FormData } from "undici"; + +import { createFetchResult, msw } from "./msw"; +import { FileReaderSync } from "./msw/read-file-sync"; + +import type { WorkerMetadata } from "../../deployment-bundle/create-worker-upload-form"; +import type { CfWorkerInit } from "../../deployment-bundle/worker"; +import type { ResponseComposition, RestContext, RestRequest } from "msw"; + +/** Create a mock handler for the request to upload a worker script. */ +export function mockUploadWorkerRequest( + options: { + available_on_subdomain?: boolean; + expectedEntry?: string | RegExp; + expectedMainModule?: string; + expectedType?: "esm" | "sw"; + expectedBindings?: unknown; + expectedModules?: Record; + expectedCompatibilityDate?: string; + expectedCompatibilityFlags?: string[]; + expectedMigrations?: CfWorkerInit["migrations"]; + expectedTailConsumers?: CfWorkerInit["tail_consumers"]; + expectedUnsafeMetaData?: Record; + expectedCapnpSchema?: string; + expectedLimits?: CfWorkerInit["limits"]; + env?: string; + legacyEnv?: boolean; + keepVars?: boolean; + tag?: string; + } = {} +) { + const { + available_on_subdomain = true, + expectedEntry, + expectedMainModule = "index.js", + expectedType = "esm", + expectedBindings, + expectedModules = {}, + expectedCompatibilityDate, + expectedCompatibilityFlags, + env = undefined, + legacyEnv = false, + expectedMigrations, + expectedTailConsumers, + expectedUnsafeMetaData, + expectedCapnpSchema, + expectedLimits, + keepVars, + } = options; + if (env && !legacyEnv) { + msw.use( + rest.put( + "*/accounts/:accountId/workers/services/:scriptName/environments/:envName", + handleUpload + ) + ); + } else { + msw.use( + rest.put( + "*/accounts/:accountId/workers/scripts/:scriptName", + handleUpload + ) + ); + } + + async function handleUpload( + req: RestRequest, + res: ResponseComposition, + ctx: RestContext + ) { + expect(req.params.accountId).toEqual("some-account-id"); + expect(req.params.scriptName).toEqual( + legacyEnv && env ? `test-name-${env}` : "test-name" + ); + if (!legacyEnv) { + expect(req.params.envName).toEqual(env); + } + expect(req.url.searchParams.get("include_subdomain_availability")).toEqual( + "true" + ); + expect(req.url.searchParams.get("excludeScript")).toEqual("true"); + + const formBody = await ( + req as MockedRequest as RestRequestWithFormData + ).formData(); + if (expectedEntry !== undefined) { + expect(formBody.get("index.js")).toMatch(expectedEntry); + } + const metadata = JSON.parse( + formBody.get("metadata") as string + ) as WorkerMetadata; + if (expectedType === "esm") { + expect(metadata.main_module).toEqual(expectedMainModule); + } else { + expect(metadata.body_part).toEqual("index.js"); + } + + if (keepVars) { + expect(metadata.keep_bindings).toEqual(["plain_text", "json"]); + } else { + expect(metadata.keep_bindings).toBeFalsy(); + } + + if ("expectedBindings" in options) { + expect(metadata.bindings).toEqual(expectedBindings); + } + if ("expectedCompatibilityDate" in options) { + expect(metadata.compatibility_date).toEqual(expectedCompatibilityDate); + } + if ("expectedCompatibilityFlags" in options) { + expect(metadata.compatibility_flags).toEqual(expectedCompatibilityFlags); + } + if ("expectedMigrations" in options) { + expect(metadata.migrations).toEqual(expectedMigrations); + } + if ("expectedTailConsumers" in options) { + expect(metadata.tail_consumers).toEqual(expectedTailConsumers); + } + if ("expectedCapnpSchema" in options) { + expect(formBody.get(metadata.capnp_schema ?? "")).toEqual( + expectedCapnpSchema + ); + } + if ("expectedLimits" in options) { + expect(metadata.limits).toEqual(expectedLimits); + } + if (expectedUnsafeMetaData !== undefined) { + Object.keys(expectedUnsafeMetaData).forEach((key) => { + expect(metadata[key]).toEqual(expectedUnsafeMetaData[key]); + }); + } + for (const [name, content] of Object.entries(expectedModules)) { + expect(formBody.get(name)).toEqual(content); + } + + return res( + ctx.json( + createFetchResult({ + available_on_subdomain, + id: "abc12345", + etag: "etag98765", + pipeline_hash: "hash9999", + mutable_pipeline_id: "mutableId", + tag: "sample-tag", + deployment_id: "Galaxy-Class", + }) + ) + ); + } +} + +// MSW FormData & Blob polyfills to test FormData requests +function mockFormDataToString(this: FormData) { + const entries = []; + for (const [key, value] of this.entries()) { + if (value instanceof Blob) { + const reader = new FileReaderSync(); + reader.readAsText(value); + const result = reader.result; + entries.push([key, result]); + } else { + entries.push([key, value]); + } + } + return JSON.stringify({ + __formdata: entries, + }); +} + +async function mockFormDataFromString(this: MockedRequest): Promise { + const { __formdata } = await this.json(); + expect(__formdata).toBeInstanceOf(Array); + + const form = new FormData(); + for (const [key, value] of __formdata) { + form.set(key, value); + } + return form; +} + +// The following two functions workaround the fact that MSW does not yet support FormData in requests. +// We use the fact that MSW relies upon `node-fetch` internally, which will call `toString()` on the FormData object, +// rather than passing it through or serializing it as a proper FormData object. +// The hack is to serialize FormData to a JSON string by overriding `FormData.toString()`. +// And then to deserialize back to a FormData object by monkey-patching a `formData()` helper onto `MockedRequest`. +FormData.prototype.toString = mockFormDataToString; +export interface RestRequestWithFormData extends MockedRequest, RestRequest { + formData(): Promise; +} +(MockedRequest.prototype as RestRequestWithFormData).formData = + mockFormDataFromString; diff --git a/packages/wrangler/src/__tests__/helpers/mock-workers-subdomain.ts b/packages/wrangler/src/__tests__/helpers/mock-workers-subdomain.ts new file mode 100644 index 000000000000..91da21c99bc8 --- /dev/null +++ b/packages/wrangler/src/__tests__/helpers/mock-workers-subdomain.ts @@ -0,0 +1,29 @@ +import { rest } from "msw"; + +import { createFetchResult, msw } from "./msw"; + +/** Create a mock handler for the request to get the account's subdomain. */ +export function mockSubDomainRequest( + subdomain = "test-sub-domain", + registeredWorkersDev = true +) { + if (registeredWorkersDev) { + msw.use( + rest.get("*/accounts/:accountId/workers/subdomain", (req, res, ctx) => { + return res.once(ctx.json(createFetchResult({ subdomain }))); + }) + ); + } else { + msw.use( + rest.get("*/accounts/:accountId/workers/subdomain", (req, res, ctx) => { + return res.once( + ctx.json( + createFetchResult(null, false, [ + { code: 10007, message: "haven't registered workers.dev" }, + ]) + ) + ); + }) + ); + } +} diff --git a/packages/wrangler/src/__tests__/standard-pricing.test.ts b/packages/wrangler/src/__tests__/standard-pricing.test.ts index 5964a70cf124..30b0e3dce788 100644 --- a/packages/wrangler/src/__tests__/standard-pricing.test.ts +++ b/packages/wrangler/src/__tests__/standard-pricing.test.ts @@ -1,7 +1,8 @@ import { rest } from "msw"; -import { mockSubDomainRequest, mockUploadWorkerRequest } from "./deploy.test"; import { mockAccountId, mockApiToken } from "./helpers/mock-account-id"; import { mockConsoleMethods } from "./helpers/mock-console"; +import { mockUploadWorkerRequest } from "./helpers/mock-upload-worker"; +import { mockSubDomainRequest } from "./helpers/mock-workers-subdomain"; import { createFetchResult, msw, @@ -11,7 +12,6 @@ import { runInTempDir } from "./helpers/run-in-tmp"; import { runWrangler } from "./helpers/run-wrangler"; import { writeWorkerSource } from "./helpers/write-worker-source"; import writeWranglerToml from "./helpers/write-wrangler-toml"; - function mockStandardEnabled(enabled: boolean, enterprise = false) { msw.use( rest.get("*/accounts/:accountId/workers/standard", (req, res, ctx) => { diff --git a/packages/wrangler/src/dev/start-server.ts b/packages/wrangler/src/dev/start-server.ts index 128b754dc293..cb7369c901f0 100644 --- a/packages/wrangler/src/dev/start-server.ts +++ b/packages/wrangler/src/dev/start-server.ts @@ -137,8 +137,7 @@ export async function startDevServer( return { stop: async () => { - stop(); - await stopWorkerRegistry(); + await Promise.all([stop(), stopWorkerRegistry()]); }, // TODO: inspectorUrl, }; @@ -296,8 +295,10 @@ async function runEsbuild({ }; } -export async function startLocalServer(props: LocalProps) { - if (!props.bundle || !props.format) return Promise.resolve({ stop() {} }); +export async function startLocalServer( + props: LocalProps +): Promise<{ stop: () => Promise }> { + if (!props.bundle || !props.format) return { async stop() {} }; // Log warnings for experimental dev-registry-dependent options if (props.bindings.services && props.bindings.services.length > 0) { @@ -317,20 +318,20 @@ export async function startLocalServer(props: LocalProps) { logger.log(chalk.dim("⎔ Starting local server...")); const config = await localPropsToConfigBundle(props); - return new Promise<{ stop: () => void }>((resolve, reject) => { + return new Promise<{ stop: () => Promise }>((resolve, reject) => { const server = new MiniflareServer(); server.addEventListener("reloaded", async (event) => { await maybeRegisterLocalWorker(event, props.name); props.onReady?.(event.url.hostname, parseInt(event.url.port)); // Note `unstable_dev` doesn't do anything with the inspector URL yet resolve({ - stop: () => { + stop: async () => { abortController.abort(); logger.log("⎔ Shutting down local server..."); + removeMiniflareServerExitListener(); // Initialization errors are also thrown asynchronously by dispose(). // The `addEventListener("error")` above should've caught them though. - server.onDispose().catch(() => {}); - removeMiniflareServerExitListener(); + await server.onDispose(); }, }); }); diff --git a/packages/wrangler/turbo.json b/packages/wrangler/turbo.json index a9989ba01661..c1fca9194b04 100644 --- a/packages/wrangler/turbo.json +++ b/packages/wrangler/turbo.json @@ -35,7 +35,8 @@ "HTTPS_PROXY", "JEST_WORKER_ID", "http_proxy", - "HTTP_PROXY" + "HTTP_PROXY", + "CI_OS" ] } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d0d38189e5d2..16a424dd384e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -66,8 +66,8 @@ importers: specifier: ^4.0.4 version: 4.3.9(@types/node@20.1.7) vitest: - specifier: ^0.31.1 - version: 0.31.4 + specifier: ^0.34.6 + version: 0.34.6 devDependencies: '@cloudflare/workers-types': specifier: ^4.20230821.0 @@ -650,9 +650,6 @@ importers: vite-tsconfig-paths: specifier: ^4.0.8 version: 4.2.0(typescript@5.0.3)(vite@4.3.9) - vitest: - specifier: ^0.30.0 - version: 0.30.1 which-pm-runs: specifier: ^1.1.0 version: 1.1.0 @@ -683,9 +680,6 @@ importers: toucan-js: specifier: ^3.1.0 version: 3.2.2(patch_hash=dxprwy4mawdnq3drjhp7shhm2m) - vitest: - specifier: ^0.31.0 - version: 0.31.4 wrangler: specifier: workspace:* version: link:../wrangler @@ -941,9 +935,6 @@ importers: undici: specifier: ^5.23.0 version: 5.23.0 - vitest: - specifier: ^0.31.4 - version: 0.31.4 wrangler: specifier: ^3.5.1 version: link:../wrangler @@ -1491,9 +1482,6 @@ importers: update-check: specifier: ^1.5.4 version: 1.5.4 - vitest: - specifier: ^0.34.4 - version: 0.34.4(supports-color@9.2.2) ws: specifier: ^8.5.0 version: 8.11.0 @@ -4990,7 +4978,6 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@sinclair/typebox': 0.27.8 - dev: true /@jest/source-map@29.6.3: resolution: {integrity: sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==} @@ -5095,7 +5082,7 @@ packages: engines: {node: '>=6.0.0'} dependencies: '@jridgewell/set-array': 1.1.0 - '@jridgewell/sourcemap-codec': 1.4.14 + '@jridgewell/sourcemap-codec': 1.4.15 dev: true /@jridgewell/gen-mapping@0.3.2: @@ -5103,7 +5090,7 @@ packages: engines: {node: '>=6.0.0'} dependencies: '@jridgewell/set-array': 1.1.0 - '@jridgewell/sourcemap-codec': 1.4.14 + '@jridgewell/sourcemap-codec': 1.4.15 '@jridgewell/trace-mapping': 0.3.17 dev: true @@ -5119,10 +5106,10 @@ packages: /@jridgewell/sourcemap-codec@1.4.14: resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} + dev: true /@jridgewell/sourcemap-codec@1.4.15: resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} - dev: true /@jridgewell/trace-mapping@0.3.17: resolution: {integrity: sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==} @@ -5135,14 +5122,14 @@ packages: resolution: {integrity: sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==} dependencies: '@jridgewell/resolve-uri': 3.1.0 - '@jridgewell/sourcemap-codec': 1.4.14 + '@jridgewell/sourcemap-codec': 1.4.15 dev: true /@jridgewell/trace-mapping@0.3.9: resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} dependencies: '@jridgewell/resolve-uri': 3.1.0 - '@jridgewell/sourcemap-codec': 1.4.14 + '@jridgewell/sourcemap-codec': 1.4.15 dev: true /@jspm/core@2.0.1: @@ -5817,7 +5804,6 @@ packages: /@sinclair/typebox@0.27.8: resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} - dev: true /@sindresorhus/is@4.6.0: resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==} @@ -6069,9 +6055,11 @@ packages: resolution: {integrity: sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==} dependencies: '@types/chai': 4.3.5 + dev: false /@types/chai@4.3.5: resolution: {integrity: sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==} + dev: false /@types/command-exists@1.2.0: resolution: {integrity: sha512-ugsxEJfsCuqMLSuCD4PIJkp5Uk2z6TCMRCgYVuhRo5cYQY3+1xXTQkSlPtkpGHuvWMjS2KTeVQXxkXRACMbM6A==} @@ -7269,7 +7257,7 @@ packages: find-up: 5.0.0 javascript-stringify: 2.1.0 lodash: 4.17.21 - mlly: 1.2.1 + mlly: 1.4.2 outdent: 0.8.0 vite: 4.3.9(@types/node@20.1.7) vite-node: 0.28.5(@types/node@20.1.7) @@ -7302,116 +7290,43 @@ packages: - supports-color dev: true - /@vitest/expect@0.30.1: - resolution: {integrity: sha512-c3kbEtN8XXJSeN81iDGq29bUzSjQhjES2WR3aColsS4lPGbivwLtas4DNUe0jD9gg/FYGIteqOenfU95EFituw==} - dependencies: - '@vitest/spy': 0.30.1 - '@vitest/utils': 0.30.1 - chai: 4.3.7 - dev: true - - /@vitest/expect@0.31.4: - resolution: {integrity: sha512-tibyx8o7GUyGHZGyPgzwiaPaLDQ9MMuCOrc03BYT0nryUuhLbL7NV2r/q98iv5STlwMgaKuFJkgBW/8iPKwlSg==} + /@vitest/expect@0.34.6: + resolution: {integrity: sha512-QUzKpUQRc1qC7qdGo7rMK3AkETI7w18gTCUrsNnyjjJKYiuUB9+TQK3QnR1unhCnWRC0AbKv2omLGQDF/mIjOw==} dependencies: - '@vitest/spy': 0.31.4 - '@vitest/utils': 0.31.4 - chai: 4.3.7 - - /@vitest/expect@0.34.4: - resolution: {integrity: sha512-XlMKX8HyYUqB8dsY8Xxrc64J2Qs9pKMt2Z8vFTL4mBWXJsg4yoALHzJfDWi8h5nkO4Zua4zjqtapQ/IluVkSnA==} - dependencies: - '@vitest/spy': 0.34.4 - '@vitest/utils': 0.34.4 - chai: 4.3.7 - dev: true - - /@vitest/runner@0.30.1: - resolution: {integrity: sha512-W62kT/8i0TF1UBCNMRtRMOBWJKRnNyv9RrjIgdUryEe0wNpGZvvwPDLuzYdxvgSckzjp54DSpv1xUbv4BQ0qVA==} - dependencies: - '@vitest/utils': 0.30.1 - concordance: 5.0.4 - p-limit: 4.0.0 - pathe: 1.1.0 - dev: true - - /@vitest/runner@0.31.4: - resolution: {integrity: sha512-Wgm6UER+gwq6zkyrm5/wbpXGF+g+UBB78asJlFkIOwyse0pz8lZoiC6SW5i4gPnls/zUcPLWS7Zog0LVepXnpg==} - dependencies: - '@vitest/utils': 0.31.4 - concordance: 5.0.4 - p-limit: 4.0.0 - pathe: 1.1.0 + '@vitest/spy': 0.34.6 + '@vitest/utils': 0.34.6 + chai: 4.3.10 + dev: false - /@vitest/runner@0.34.4: - resolution: {integrity: sha512-hwwdB1StERqUls8oV8YcpmTIpVeJMe4WgYuDongVzixl5hlYLT2G8afhcdADeDeqCaAmZcSgLTLtqkjPQF7x+w==} + /@vitest/runner@0.34.6: + resolution: {integrity: sha512-1CUQgtJSLF47NnhN+F9X2ycxUP0kLHQ/JWvNHbeBfwW8CzEGgeskzNnHDyv1ieKTltuR6sdIHV+nmR6kPxQqzQ==} dependencies: - '@vitest/utils': 0.34.4 + '@vitest/utils': 0.34.6 p-limit: 4.0.0 pathe: 1.1.1 - dev: true - - /@vitest/snapshot@0.30.1: - resolution: {integrity: sha512-fJZqKrE99zo27uoZA/azgWyWbFvM1rw2APS05yB0JaLwUIg9aUtvvnBf4q7JWhEcAHmSwbrxKFgyBUga6tq9Tw==} - dependencies: - magic-string: 0.30.0 - pathe: 1.1.0 - pretty-format: 27.5.1 - dev: true - - /@vitest/snapshot@0.31.4: - resolution: {integrity: sha512-LemvNumL3NdWSmfVAMpXILGyaXPkZbG5tyl6+RQSdcHnTj6hvA49UAI8jzez9oQyE/FWLKRSNqTGzsHuk89LRA==} - dependencies: - magic-string: 0.30.0 - pathe: 1.1.0 - pretty-format: 27.5.1 + dev: false - /@vitest/snapshot@0.34.4: - resolution: {integrity: sha512-GCsh4coc3YUSL/o+BPUo7lHQbzpdttTxL6f4q0jRx2qVGoYz/cyTRDJHbnwks6TILi6560bVWoBpYC10PuTLHw==} + /@vitest/snapshot@0.34.6: + resolution: {integrity: sha512-B3OZqYn6k4VaN011D+ve+AA4whM4QkcwcrwaKwAbyyvS/NB1hCWjFIBQxAQQSQir9/RtyAAGuq+4RJmbn2dH4w==} dependencies: magic-string: 0.30.3 pathe: 1.1.1 pretty-format: 29.7.0 - dev: true - - /@vitest/spy@0.30.1: - resolution: {integrity: sha512-YfJeIf37GvTZe04ZKxzJfnNNuNSmTEGnla2OdL60C8od16f3zOfv9q9K0nNii0NfjDJRt/CVN/POuY5/zTS+BA==} - dependencies: - tinyspy: 2.1.0 - dev: true - - /@vitest/spy@0.31.4: - resolution: {integrity: sha512-3ei5ZH1s3aqbEyftPAzSuunGICRuhE+IXOmpURFdkm5ybUADk+viyQfejNk6q8M5QGX8/EVKw+QWMEP3DTJDag==} - dependencies: - tinyspy: 2.1.0 + dev: false - /@vitest/spy@0.34.4: - resolution: {integrity: sha512-PNU+fd7DUPgA3Ya924b1qKuQkonAW6hL7YUjkON3wmBwSTIlhOSpy04SJ0NrRsEbrXgMMj6Morh04BMf8k+w0g==} + /@vitest/spy@0.34.6: + resolution: {integrity: sha512-xaCvneSaeBw/cz8ySmF7ZwGvL0lBjfvqc1LpQ/vcdHEvpLn3Ff1vAvjw+CoGn0802l++5L/pxb7whwcWAw+DUQ==} dependencies: tinyspy: 2.1.1 - dev: true - - /@vitest/utils@0.30.1: - resolution: {integrity: sha512-/c8Xv2zUVc+rnNt84QF0Y0zkfxnaGhp87K2dYJMLtLOIckPzuxLVzAtFCicGFdB4NeBHNzTRr1tNn7rCtQcWFA==} - dependencies: - concordance: 5.0.4 - loupe: 2.3.6 - pretty-format: 27.5.1 - dev: true - - /@vitest/utils@0.31.4: - resolution: {integrity: sha512-DobZbHacWznoGUfYU8XDPY78UubJxXfMNY1+SUdOp1NsI34eopSA6aZMeaGu10waSOeYwE8lxrd/pLfT0RMxjQ==} - dependencies: - concordance: 5.0.4 - loupe: 2.3.6 - pretty-format: 27.5.1 + dev: false - /@vitest/utils@0.34.4: - resolution: {integrity: sha512-yR2+5CHhp/K4ySY0Qtd+CAL9f5Yh1aXrKfAT42bq6CtlGPh92jIDDDSg7ydlRow1CP+dys4TrOrbELOyNInHSg==} + /@vitest/utils@0.34.6: + resolution: {integrity: sha512-IG5aDD8S6zlvloDsnzHw0Ut5xczlF+kv2BOTo+iXfPr54Yhi5qbVOgGB1hZaVq4iJ4C/MZ2J0y15IlsV/ZcI0A==} dependencies: diff-sequences: 29.6.3 loupe: 2.3.6 pretty-format: 29.7.0 - dev: true + dev: false /@web3-storage/multipart-parser@1.0.0: resolution: {integrity: sha512-BEO6al7BYqcnfX15W2cnGR+Q566ACXAT9UQykORCWW80lmkpWsnEob6zJS1ZVBKsSJC8+7vJkHwlp+lXG1UCdw==} @@ -7459,11 +7374,6 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - /acorn@8.8.2: - resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} - engines: {node: '>=0.4.0'} - hasBin: true - /agent-base@6.0.2: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} @@ -7742,6 +7652,7 @@ packages: /assertion-error@1.1.0: resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} + dev: false /assign-symbols@1.0.0: resolution: {integrity: sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw==} @@ -8090,6 +8001,7 @@ packages: /blueimp-md5@2.19.0: resolution: {integrity: sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==} + dev: true /body-parser@1.20.0(supports-color@9.2.2): resolution: {integrity: sha512-DfJ+q6EPcGKZD1QWUjSpqp+Q7bDQTsQIF4zfUAtZ6qk+H/3/QRhg9CEp39ss+/T2vw0+HaidC0ecJj/DRLIaKg==} @@ -8387,17 +8299,18 @@ packages: nofilter: 3.1.0 dev: true - /chai@4.3.7: - resolution: {integrity: sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==} + /chai@4.3.10: + resolution: {integrity: sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==} engines: {node: '>=4'} dependencies: assertion-error: 1.1.0 - check-error: 1.0.2 + check-error: 1.0.3 deep-eql: 4.1.3 - get-func-name: 2.0.0 + get-func-name: 2.0.2 loupe: 2.3.6 pathval: 1.1.1 type-detect: 4.0.8 + dev: false /chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} @@ -8481,8 +8394,11 @@ packages: /chardet@0.7.0: resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} - /check-error@1.0.2: - resolution: {integrity: sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==} + /check-error@1.0.3: + resolution: {integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==} + dependencies: + get-func-name: 2.0.2 + dev: false /chokidar@3.5.3: resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} @@ -8778,6 +8694,7 @@ packages: md5-hex: 3.0.1 semver: 7.5.4 well-known-symbols: 2.0.0 + dev: true /concurrently@7.3.0: resolution: {integrity: sha512-IiDwm+8DOcFEInca494A8V402tNTQlJaYq78RF2rijOrKEk/AOHTxhN4U1cp7GYKYX5Q6Ymh1dLTBlzIMN0ikA==} @@ -9092,6 +9009,7 @@ packages: engines: {node: '>=6'} dependencies: time-zone: 1.0.0 + dev: true /deasync@0.1.28: resolution: {integrity: sha512-QqLF6inIDwiATrfROIyQtwOQxjZuek13WRYZ7donU5wJPLoP67MnYxA6QtqdvdBy2mMqv5m3UefBVdJjvevOYg==} @@ -9181,6 +9099,7 @@ packages: engines: {node: '>=6'} dependencies: type-detect: 4.0.8 + dev: false /deep-equal@2.1.0: resolution: {integrity: sha512-2pxgvWu3Alv1PoWEyVg7HS8YhGlUFUV7N5oOvfL6d+7xAmLSemMwv/c8Zv/i9KFzxV5Kt5CAvQc70fLwVuf4UA==} @@ -9383,7 +9302,6 @@ packages: /diff-sequences@29.6.3: resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dev: true /diff@4.0.2: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} @@ -10833,6 +10751,7 @@ packages: /fast-diff@1.2.0: resolution: {integrity: sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==} + dev: true /fast-glob@3.2.11: resolution: {integrity: sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==} @@ -11245,8 +11164,9 @@ packages: resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} engines: {node: 6.* || 8.* || >= 10.*} - /get-func-name@2.0.0: - resolution: {integrity: sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==} + /get-func-name@2.0.2: + resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==} + dev: false /get-intrinsic@1.2.1: resolution: {integrity: sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==} @@ -13143,6 +13063,7 @@ packages: /js-string-escape@1.0.1: resolution: {integrity: sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg==} engines: {node: '>= 0.8'} + dev: true /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -13379,6 +13300,7 @@ packages: /local-pkg@0.4.3: resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==} engines: {node: '>=14'} + dev: false /localforage@1.10.0: resolution: {integrity: sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==} @@ -13510,7 +13432,8 @@ packages: /loupe@2.3.6: resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==} dependencies: - get-func-name: 2.0.0 + get-func-name: 2.0.2 + dev: false /lower-case-first@1.0.2: resolution: {integrity: sha512-UuxaYakO7XeONbKrZf5FEgkantPf5DUqDayzP5VXZrtRPdH86s4kN47I8B3TW10S4QKiE3ziHNf3kRN//okHjA==} @@ -13565,18 +13488,12 @@ packages: sourcemap-codec: 1.4.8 dev: false - /magic-string@0.30.0: - resolution: {integrity: sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==} - engines: {node: '>=12'} - dependencies: - '@jridgewell/sourcemap-codec': 1.4.14 - /magic-string@0.30.3: resolution: {integrity: sha512-B7xGbll2fG/VjP+SWg4sX3JynwIU0mjoTc6MPpKNuIvftk6u6vqhDnk1R80b8C2GBR6ywqy+1DcKBrevBg+bmw==} engines: {node: '>=12'} dependencies: '@jridgewell/sourcemap-codec': 1.4.15 - dev: true + dev: false /make-dir@3.1.0: resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} @@ -13654,6 +13571,7 @@ packages: engines: {node: '>=8'} dependencies: blueimp-md5: 2.19.0 + dev: true /mdast-util-definitions@5.1.1: resolution: {integrity: sha512-rQ+Gv7mHttxHOBx2dkF4HWTg+EE+UR78ptQWDylzPKaQuVGdG4HIoY3SrS/pCp80nZ04greFvXbVFHT+uf0JVQ==} @@ -14298,14 +14216,6 @@ packages: hasBin: true dev: true - /mlly@1.2.1: - resolution: {integrity: sha512-1aMEByaWgBPEbWV2BOPEMySRrzl7rIHXmQxam4DM8jVjalTQDjpN2ZKOLUrwyhfZQO7IXHml2StcHMhooDeEEQ==} - dependencies: - acorn: 8.10.0 - pathe: 1.1.0 - pkg-types: 1.0.3 - ufo: 1.1.2 - /mlly@1.4.2: resolution: {integrity: sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==} dependencies: @@ -14313,7 +14223,6 @@ packages: pathe: 1.1.1 pkg-types: 1.0.3 ufo: 1.3.0 - dev: true /mock-socket@9.3.1: resolution: {integrity: sha512-qxBgB7Qa2sEQgHFjj0dSigq7fX4k6Saisd5Nelwp2q8mlbAFh5dHV9JTTlF8viYJLSSWgMCZFUom8PJcMNBoJw==} @@ -15153,15 +15062,12 @@ packages: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} - /pathe@1.1.0: - resolution: {integrity: sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==} - /pathe@1.1.1: resolution: {integrity: sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==} - dev: true /pathval@1.1.1: resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} + dev: false /peek-stream@1.1.3: resolution: {integrity: sha512-FhJ+YbOSBb9/rIl2ZeE/QHEsWn7PqNYt8ARAY3kIgNGOk13g9FGyIY6JIl/xB/3TFRVoTv5as0l11weORrTekA==} @@ -15228,8 +15134,8 @@ packages: resolution: {integrity: sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==} dependencies: jsonc-parser: 3.2.0 - mlly: 1.2.1 - pathe: 1.1.0 + mlly: 1.4.2 + pathe: 1.1.1 /plur@5.1.0: resolution: {integrity: sha512-VP/72JeXqak2KiOzjgKtQen5y3IZHn+9GOuLDafPv0eXa47xq0At93XahYBs26MsifCQ4enGKwbjBTKgb9QJXg==} @@ -15429,6 +15335,7 @@ packages: ansi-regex: 5.0.1 ansi-styles: 5.2.0 react-is: 17.0.2 + dev: true /pretty-format@29.7.0: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} @@ -15437,7 +15344,6 @@ packages: '@jest/schemas': 29.6.3 ansi-styles: 5.2.0 react-is: 18.2.0 - dev: true /pretty-ms@7.0.1: resolution: {integrity: sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q==} @@ -16651,6 +16557,7 @@ packages: /siginfo@2.0.0: resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} + dev: false /signal-exit@3.0.7: resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} @@ -16919,6 +16826,7 @@ packages: /stackback@0.0.2: resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} + dev: false /stacktracey@2.1.8: resolution: {integrity: sha512-Kpij9riA+UNg7TnphqjH7/CzctQ/owJGNbFkfEeve4Z4uxT5+JapVLFXcsurIfN34gnTWZNJ/f7NMG0E8JDzTw==} @@ -16944,12 +16852,9 @@ packages: engines: {node: '>= 0.8'} dev: true - /std-env@3.3.2: - resolution: {integrity: sha512-uUZI65yrV2Qva5gqE0+A7uVAvO40iPo6jGhs7s8keRfHCmtg+uB2X6EiLGCI9IgL1J17xGhvoOqSz79lzICPTA==} - /std-env@3.4.3: resolution: {integrity: sha512-f9aPhy8fYBuMN+sNfakZV18U39PbalgjXG3lLB9WkaYTxijru61wb57V9wxxNthXM5Sd88ETBWi29qLAsHO52Q==} - dev: true + dev: false /stoppable@1.1.0: resolution: {integrity: sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==} @@ -17136,6 +17041,7 @@ packages: resolution: {integrity: sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==} dependencies: acorn: 8.10.0 + dev: false /stripe@9.16.0: resolution: {integrity: sha512-Dn8K+jSoQcXjxCobRI4HXUdHjOXsiF/KszK49fJnkbeCFjZ3EZxLG2JiM/CX+Hcq27NBDtv/Sxhvy+HhTmvyaQ==} @@ -17308,6 +17214,7 @@ packages: /time-zone@1.0.0: resolution: {integrity: sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA==} engines: {node: '>=4'} + dev: true /timeago.js@4.0.2: resolution: {integrity: sha512-a7wPxPdVlQL7lqvitHGGRsofhdwtkoSXPGATFuSOA2i1ZNQEPLrGnj68vOp2sOJTCFAQVXPeNMX/GctBaO9L2w==} @@ -17319,6 +17226,7 @@ packages: /tinybench@2.5.0: resolution: {integrity: sha512-kRwSG8Zx4tjF9ZiyH4bhaebu+EDz1BOx9hOigYHlUW4xxI/wKIUQUqo018UlU4ar6ATPBsaMrdbKZ+tmPdohFA==} + dev: false /tinycolor2@1.6.0: resolution: {integrity: sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==} @@ -17331,28 +17239,15 @@ packages: tinycolor2: 1.6.0 dev: true - /tinypool@0.4.0: - resolution: {integrity: sha512-2ksntHOKf893wSAH4z/+JbPpi92esw8Gn9N2deXX+B0EO92hexAVI9GIZZPx7P5aYo5KULfeOSt3kMOmSOy6uA==} - engines: {node: '>=14.0.0'} - dev: true - - /tinypool@0.5.0: - resolution: {integrity: sha512-paHQtnrlS1QZYKF/GnLoOM/DN9fqaGOFbCbxzAhwniySnzl9Ebk8w73/dd34DAhe/obUbPAOldTyYXQZxnPBPQ==} - engines: {node: '>=14.0.0'} - /tinypool@0.7.0: resolution: {integrity: sha512-zSYNUlYSMhJ6Zdou4cJwo/p7w5nmAH17GRfU/ui3ctvjXFErXXkruT4MWW6poDeXgCaIBlGLrfU6TbTXxyGMww==} engines: {node: '>=14.0.0'} - dev: true - - /tinyspy@2.1.0: - resolution: {integrity: sha512-7eORpyqImoOvkQJCSkL0d0mB4NHHIFAy4b1u8PHdDa7SjGS2njzl6/lyGoZLm+eyYEtlUmFGE0rFj66SWxZgQQ==} - engines: {node: '>=14.0.0'} + dev: false /tinyspy@2.1.1: resolution: {integrity: sha512-XPJL2uSzcOyBMky6OFrusqWlzfFrXtE0hPuMgW8A2HmaqrPo4ZQHRN/V0QXN3FSjKxpsbRrFc5LI7KOwBsT1/w==} engines: {node: '>=14.0.0'} - dev: true + dev: false /title-case@2.1.1: resolution: {integrity: sha512-EkJoZ2O3zdCz3zJsYCsxyq2OC5hrxR9mfdd5I+w8h/tmFfeOxJ+vvkxsKxdmN0WtS9zLdHEgfgVOiMVgv+Po4Q==} @@ -17803,12 +17698,8 @@ packages: hasBin: true dev: true - /ufo@1.1.2: - resolution: {integrity: sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==} - /ufo@1.3.0: resolution: {integrity: sha512-bRn3CsoojyNStCZe0BG0Mt4Nr/4KF+rhFlnNXybgqt5pXHNFRlqinSoQaTrGyzE4X8aHplSb+TorH+COin9Yxw==} - dev: true /uglify-js@3.17.4: resolution: {integrity: sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==} @@ -18150,8 +18041,8 @@ packages: dependencies: cac: 6.7.14 debug: 4.3.4(supports-color@9.2.2) - mlly: 1.2.1 - pathe: 1.1.0 + mlly: 1.4.2 + pathe: 1.1.1 picocolors: 1.0.0 source-map: 0.6.1 source-map-support: 0.5.21 @@ -18166,49 +18057,8 @@ packages: - terser dev: true - /vite-node@0.30.1(@types/node@20.1.7): - resolution: {integrity: sha512-vTikpU/J7e6LU/8iM3dzBo8ZhEiKZEKRznEMm+mJh95XhWaPrJQraT/QsT2NWmuEf+zgAoMe64PKT7hfZ1Njmg==} - engines: {node: '>=v14.18.0'} - hasBin: true - dependencies: - cac: 6.7.14 - debug: 4.3.4(supports-color@9.2.2) - mlly: 1.2.1 - pathe: 1.1.0 - picocolors: 1.0.0 - vite: 4.3.9(@types/node@20.1.7) - transitivePeerDependencies: - - '@types/node' - - less - - sass - - stylus - - sugarss - - supports-color - - terser - dev: true - - /vite-node@0.31.4(@types/node@20.1.7): - resolution: {integrity: sha512-uzL377GjJtTbuc5KQxVbDu2xfU/x0wVjUtXQR2ihS21q/NK6ROr4oG0rsSkBBddZUVCwzfx22in76/0ZZHXgkQ==} - engines: {node: '>=v14.18.0'} - hasBin: true - dependencies: - cac: 6.7.14 - debug: 4.3.4(supports-color@9.2.2) - mlly: 1.2.1 - pathe: 1.1.0 - picocolors: 1.0.0 - vite: 4.3.9(@types/node@20.1.7) - transitivePeerDependencies: - - '@types/node' - - less - - sass - - stylus - - sugarss - - supports-color - - terser - - /vite-node@0.34.4(@types/node@18.16.10)(supports-color@9.2.2): - resolution: {integrity: sha512-ho8HtiLc+nsmbwZMw8SlghESEE3KxJNp04F/jPUCLVvaURwt0d+r9LxEqCX5hvrrOQ0GSyxbYr5ZfRYhQ0yVKQ==} + /vite-node@0.34.6(@types/node@18.16.10): + resolution: {integrity: sha512-nlBMJ9x6n7/Amaz6F3zJ97EBwR2FkzhBRxF5e+jE6LA3yi6Wtc2lyTij1OnDMIr34v5g/tVQtsVAzhT0jc5ygA==} engines: {node: '>=v14.18.0'} hasBin: true dependencies: @@ -18226,7 +18076,7 @@ packages: - sugarss - supports-color - terser - dev: true + dev: false /vite-plugin-rewrite-all@1.0.1(vite@4.3.9): resolution: {integrity: sha512-W0DAchC8ynuQH0lYLIu5/5+JGfYlUTRD8GGNtHFXRJX4FzzB9MajtqHBp26zq/ly9sDt5BqrfdT08rv3RbB0LQ==} @@ -18286,7 +18136,7 @@ packages: rollup: 3.25.1 optionalDependencies: fsevents: 2.3.2 - dev: true + dev: false /vite@4.3.9(@types/node@20.1.7): resolution: {integrity: sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==} @@ -18320,138 +18170,8 @@ packages: optionalDependencies: fsevents: 2.3.2 - /vitest@0.30.1: - resolution: {integrity: sha512-y35WTrSTlTxfMLttgQk4rHcaDkbHQwDP++SNwPb+7H8yb13Q3cu2EixrtHzF27iZ8v0XCciSsLg00RkPAzB/aA==} - engines: {node: '>=v14.18.0'} - hasBin: true - peerDependencies: - '@edge-runtime/vm': '*' - '@vitest/browser': '*' - '@vitest/ui': '*' - happy-dom: '*' - jsdom: '*' - playwright: '*' - safaridriver: '*' - webdriverio: '*' - peerDependenciesMeta: - '@edge-runtime/vm': - optional: true - '@vitest/browser': - optional: true - '@vitest/ui': - optional: true - happy-dom: - optional: true - jsdom: - optional: true - playwright: - optional: true - safaridriver: - optional: true - webdriverio: - optional: true - dependencies: - '@types/chai': 4.3.5 - '@types/chai-subset': 1.3.3 - '@types/node': 20.1.7 - '@vitest/expect': 0.30.1 - '@vitest/runner': 0.30.1 - '@vitest/snapshot': 0.30.1 - '@vitest/spy': 0.30.1 - '@vitest/utils': 0.30.1 - acorn: 8.8.2 - acorn-walk: 8.2.0 - cac: 6.7.14 - chai: 4.3.7 - concordance: 5.0.4 - debug: 4.3.4(supports-color@9.2.2) - local-pkg: 0.4.3 - magic-string: 0.30.0 - pathe: 1.1.0 - picocolors: 1.0.0 - source-map: 0.6.1 - std-env: 3.3.2 - strip-literal: 1.0.1 - tinybench: 2.5.0 - tinypool: 0.4.0 - vite: 4.3.9(@types/node@20.1.7) - vite-node: 0.30.1(@types/node@20.1.7) - why-is-node-running: 2.2.2 - transitivePeerDependencies: - - less - - sass - - stylus - - sugarss - - supports-color - - terser - dev: true - - /vitest@0.31.4: - resolution: {integrity: sha512-GoV0VQPmWrUFOZSg3RpQAPN+LPmHg2/gxlMNJlyxJihkz6qReHDV6b0pPDcqFLNEPya4tWJ1pgwUNP9MLmUfvQ==} - engines: {node: '>=v14.18.0'} - hasBin: true - peerDependencies: - '@edge-runtime/vm': '*' - '@vitest/browser': '*' - '@vitest/ui': '*' - happy-dom: '*' - jsdom: '*' - playwright: '*' - safaridriver: '*' - webdriverio: '*' - peerDependenciesMeta: - '@edge-runtime/vm': - optional: true - '@vitest/browser': - optional: true - '@vitest/ui': - optional: true - happy-dom: - optional: true - jsdom: - optional: true - playwright: - optional: true - safaridriver: - optional: true - webdriverio: - optional: true - dependencies: - '@types/chai': 4.3.5 - '@types/chai-subset': 1.3.3 - '@types/node': 20.1.7 - '@vitest/expect': 0.31.4 - '@vitest/runner': 0.31.4 - '@vitest/snapshot': 0.31.4 - '@vitest/spy': 0.31.4 - '@vitest/utils': 0.31.4 - acorn: 8.8.2 - acorn-walk: 8.2.0 - cac: 6.7.14 - chai: 4.3.7 - concordance: 5.0.4 - debug: 4.3.4(supports-color@9.2.2) - local-pkg: 0.4.3 - magic-string: 0.30.0 - pathe: 1.1.0 - picocolors: 1.0.0 - std-env: 3.3.2 - strip-literal: 1.0.1 - tinybench: 2.5.0 - tinypool: 0.5.0 - vite: 4.3.9(@types/node@20.1.7) - vite-node: 0.31.4(@types/node@20.1.7) - why-is-node-running: 2.2.2 - transitivePeerDependencies: - - less - - sass - - stylus - - sugarss - - supports-color - - terser - - /vitest@0.34.4(supports-color@9.2.2): - resolution: {integrity: sha512-SE/laOsB6995QlbSE6BtkpXDeVNLJc1u2LHRG/OpnN4RsRzM3GQm4nm3PQCK5OBtrsUqnhzLdnT7se3aeNGdlw==} + /vitest@0.34.6: + resolution: {integrity: sha512-+5CALsOvbNKnS+ZHMXtuUC7nL8/7F1F2DnHGjSsszX8zCjWSSviphCb/NuS9Nzf4Q03KyyDRBAXhF/8lffME4Q==} engines: {node: '>=v14.18.0'} hasBin: true peerDependencies: @@ -18484,15 +18204,15 @@ packages: '@types/chai': 4.3.5 '@types/chai-subset': 1.3.3 '@types/node': 18.16.10 - '@vitest/expect': 0.34.4 - '@vitest/runner': 0.34.4 - '@vitest/snapshot': 0.34.4 - '@vitest/spy': 0.34.4 - '@vitest/utils': 0.34.4 + '@vitest/expect': 0.34.6 + '@vitest/runner': 0.34.6 + '@vitest/snapshot': 0.34.6 + '@vitest/spy': 0.34.6 + '@vitest/utils': 0.34.6 acorn: 8.10.0 acorn-walk: 8.2.0 cac: 6.7.14 - chai: 4.3.7 + chai: 4.3.10 debug: 4.3.4(supports-color@9.2.2) local-pkg: 0.4.3 magic-string: 0.30.3 @@ -18503,7 +18223,7 @@ packages: tinybench: 2.5.0 tinypool: 0.7.0 vite: 4.3.9(@types/node@18.16.10) - vite-node: 0.34.4(@types/node@18.16.10)(supports-color@9.2.2) + vite-node: 0.34.6(@types/node@18.16.10) why-is-node-running: 2.2.2 transitivePeerDependencies: - less @@ -18512,7 +18232,7 @@ packages: - sugarss - supports-color - terser - dev: true + dev: false /vm2@3.9.15: resolution: {integrity: sha512-XqNqknHGw2avJo13gbIwLNZUumvrSHc9mLqoadFZTpo3KaNEJoe1I0lqTFhRXmXD7WkLyG01aaraXdXT0pa4ag==} @@ -18562,6 +18282,7 @@ packages: /well-known-symbols@2.0.0: resolution: {integrity: sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q==} engines: {node: '>=6'} + dev: true /whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} @@ -18651,6 +18372,7 @@ packages: dependencies: siginfo: 2.0.0 stackback: 0.0.2 + dev: false /widest-line@3.1.0: resolution: {integrity: sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==} diff --git a/templates/worker-prospector/package.json b/templates/worker-prospector/package.json index 540ac6e2d65f..6c3fc76ec8c8 100644 --- a/templates/worker-prospector/package.json +++ b/templates/worker-prospector/package.json @@ -17,7 +17,6 @@ "@databases/sql": "^3.2.0", "better-sqlite3": "^7.6.2", "typescript": "^4.9.4", - "vitest": "^0.31.0", "wrangler": "^3.0.0" } } diff --git a/templates/worker-router/package.json b/templates/worker-router/package.json index e628c130b065..994d22ebfdde 100644 --- a/templates/worker-router/package.json +++ b/templates/worker-router/package.json @@ -11,7 +11,6 @@ "itty-router": "^2.6.1" }, "devDependencies": { - "vitest": "^0.31.0", "wrangler": "^3.0.0" } } diff --git a/templates/worker-typescript/package.json b/templates/worker-typescript/package.json index 71dc3ed283b7..f1bb1c8706cd 100644 --- a/templates/worker-typescript/package.json +++ b/templates/worker-typescript/package.json @@ -10,7 +10,6 @@ }, "devDependencies": { "@cloudflare/workers-types": "^4.20231016.0", - "vitest": "^0.31.0", "typescript": "^5.0.4", "wrangler": "^3.0.0" } diff --git a/templates/worker/package.json b/templates/worker/package.json index 247dfec9096c..24910a79674d 100644 --- a/templates/worker/package.json +++ b/templates/worker/package.json @@ -8,7 +8,6 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^0.31.0", "wrangler": "^3.0.0" } } diff --git a/turbo.json b/turbo.json index 6cc24334132e..4a2025de8889 100644 --- a/turbo.json +++ b/turbo.json @@ -3,6 +3,7 @@ "remoteCache": { "signature": true }, + "globalEnv": ["CI_OS", "NODE_VERSION"], "pipeline": { "wrangler#dev": { "persistent": true, diff --git a/vitest.workspace.ts b/vitest.workspace.ts new file mode 100644 index 000000000000..568eb2f43139 --- /dev/null +++ b/vitest.workspace.ts @@ -0,0 +1 @@ +export default ["packages/*/vitest.config.ts", "fixtures/*/vitest.config.ts"];