Skip to content

Commit

Permalink
chore: avoid inlining deps in vitest (#21316)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jun 2, 2023
1 parent 7512a52 commit 5614ef9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
10 changes: 2 additions & 8 deletions packages/nuxt/test/treeshake-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down Expand Up @@ -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<Options & {devServer: {config: {server: any}}}> }[] = [
const stateToTest: { name: string, options: Partial<Options & { devServer: { config: { server: any } } }> }[] = [
{
name: 'prod',
options: {
Expand Down Expand Up @@ -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()
})
}
})
1 change: 0 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5614ef9

Please sign in to comment.