From 5614ef9b8f8a415f9f5d7e92afd24671cba27d56 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 2 Jun 2023 12:12:33 +0100 Subject: [PATCH] chore: avoid inlining deps in vitest (#21316) --- packages/nuxt/test/treeshake-client.test.ts | 10 ++-------- vitest.config.ts | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/nuxt/test/treeshake-client.test.ts b/packages/nuxt/test/treeshake-client.test.ts index 5fb2545a37..ac36ba584f 100644 --- a/packages/nuxt/test/treeshake-client.test.ts +++ b/packages/nuxt/test/treeshake-client.test.ts @@ -9,12 +9,6 @@ import _vuePlugin from '@vitejs/plugin-vue' import { TreeShakeTemplatePlugin } from '../src/components/tree-shake' import { fixtureDir, normalizeLineEndings } from './utils' -vi.mock('node:crypto', () => ({ - update: vi.fn().mockReturnThis(), - digest: vi.fn().mockReturnValue('one-hash-to-rule-them-all'), - createHash: vi.fn().mockReturnThis() -})) - // mock due to differences of results between windows and linux vi.spyOn(path, 'relative').mockImplementation((from: string, to: string) => { if (to.includes('SomeComponent')) { @@ -90,7 +84,7 @@ async function SFCCompile (name: string, source: string, options: Options, ssr = return typeof result === 'string' ? result : result?.code } -const stateToTest: {name: string, options: Partial }[] = [ +const stateToTest: { name: string, options: Partial }[] = [ { name: 'prod', options: { @@ -188,7 +182,7 @@ describe('treeshake client only in ssr', () => { expect(treeshaken).not.toContain('ssrRenderComponent(_unref(HelloWorld') expect(treeshaken).toContain('ssrRenderComponent(_unref(Glob') } - expect(treeshaken).toMatchSnapshot() + expect(treeshaken.replace(/data-v-[\d\w]{8}/g, 'data-v-one-hash').replace(/scoped=[\d\w]{8}/g, 'scoped=one-hash')).toMatchSnapshot() }) } }) diff --git a/vitest.config.ts b/vitest.config.ts index 048dfb643b..4380b49ac4 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -14,7 +14,6 @@ export default defineConfig({ test: { globalSetup: 'test/setup.ts', testTimeout: isWindows ? 60000 : 10000, - deps: { inline: ['@vitejs/plugin-vue'] }, // Excluded plugin because it should throw an error when accidentally loaded via Nuxt exclude: [...configDefaults.exclude, '**/this-should-not-load.spec.js'], maxThreads: process.env.TEST_ENV === 'dev' ? 1 : undefined,