diff --git a/.github/actions/setup-and-cache/action.yml b/.github/actions/setup-and-cache/action.yml index b5528ea385ba..056f2a87748b 100644 --- a/.github/actions/setup-and-cache/action.yml +++ b/.github/actions/setup-and-cache/action.yml @@ -4,7 +4,7 @@ inputs: node-version: required: false description: Node version for setup-node - default: 18.x + default: 20.x runs: using: composite diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bdaf5c4d67ff..5056a27eed4d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,12 +57,12 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node_version: [18] + node_version: [18, 20] include: - os: macos-latest - node_version: 18 + node_version: 20 - os: windows-latest - node_version: 18 + node_version: 20 fail-fast: false steps: @@ -97,7 +97,7 @@ jobs: - uses: ./.github/actions/setup-and-cache with: - node-version: 18 + node-version: 20 - name: Install run: pnpm i @@ -120,7 +120,7 @@ jobs: - uses: ./.github/actions/setup-and-cache with: - node-version: 18 + node-version: 20 - uses: browser-actions/setup-chrome@v1 - uses: browser-actions/setup-firefox@v1 @@ -160,7 +160,7 @@ jobs: - uses: ./.github/actions/setup-and-cache with: - node-version: 18 + node-version: 20 - uses: browser-actions/setup-chrome@v1 - uses: browser-actions/setup-edge@v1 @@ -191,7 +191,7 @@ jobs: - uses: ./.github/actions/setup-and-cache with: - node-version: 18 + node-version: 20 - name: Install run: sudo pnpm i --frozen-lockfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18409fee520a..8aadd6127d7c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: 18.x + node-version: 20.x - run: npx changelogithub env: diff --git a/packages/vitest/src/runtime/child.ts b/packages/vitest/src/runtime/child.ts index 7314444ea3f3..a01bf5cb8779 100644 --- a/packages/vitest/src/runtime/child.ts +++ b/packages/vitest/src/runtime/child.ts @@ -75,8 +75,12 @@ async function init(ctx: ChildContext) { isChildProcess: true, } - // @ts-expect-error I know what I am doing :P - globalThis.__vitest_worker__ = state + Object.defineProperty(globalThis, '__vitest_worker__', { + value: state, + configurable: true, + writable: true, + enumerable: false, + }) if (ctx.invalidates) { ctx.invalidates.forEach((fsPath) => { diff --git a/packages/vitest/src/runtime/vm.ts b/packages/vitest/src/runtime/vm.ts index 6f4ce418d22f..3dd0729a6408 100644 --- a/packages/vitest/src/runtime/vm.ts +++ b/packages/vitest/src/runtime/vm.ts @@ -86,7 +86,12 @@ export async function run(ctx: WorkerContext) { if (!isContext(context)) throw new TypeError(`Environment ${ctx.environment.name} doesn't provide a valid context. It should be created by "vm.createContext" method.`) - context.__vitest_worker__ = state + Object.defineProperty(context, '__vitest_worker__', { + value: state, + configurable: true, + writable: true, + enumerable: false, + }) // this is unfortunately needed for our own dependencies // we need to find a way to not rely on this by default // because browser doesn't provide these globals diff --git a/packages/vitest/src/runtime/worker.ts b/packages/vitest/src/runtime/worker.ts index d31f209cd716..979a478ebbf7 100644 --- a/packages/vitest/src/runtime/worker.ts +++ b/packages/vitest/src/runtime/worker.ts @@ -60,8 +60,12 @@ async function init(ctx: WorkerContext) { rpc, } - // @ts-expect-error I know what I am doing :P - globalThis.__vitest_worker__ = state + Object.defineProperty(globalThis, '__vitest_worker__', { + value: state, + configurable: true, + writable: true, + enumerable: false, + }) if (ctx.invalidates) { ctx.invalidates.forEach((fsPath) => { diff --git a/test/edge-runtime/test/node.test.ts b/test/edge-runtime/test/node.test.ts deleted file mode 100644 index 1a5f47e1b27b..000000000000 --- a/test/edge-runtime/test/node.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { expect, test } from 'vitest' - -test('node env should not have crypto', () => { - expect(globalThis).not.toHaveProperty('crypto') -})