From 8d3bd4f9fa2da12452cf6cd6f68339d3dc557c58 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 17 Mar 2025 13:15:46 +0000 Subject: [PATCH] test: normalise scoped css + pass logger to `configResolved` --- packages/nuxt/test/treeshake-client.test.ts | 2 ++ test/basic.test.ts | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/test/treeshake-client.test.ts b/packages/nuxt/test/treeshake-client.test.ts index f9b8a1f9d1..05302a9be9 100644 --- a/packages/nuxt/test/treeshake-client.test.ts +++ b/packages/nuxt/test/treeshake-client.test.ts @@ -3,6 +3,7 @@ import path from 'node:path' import { describe, expect, it, vi } from 'vitest' import * as VueCompilerSFC from 'vue/compiler-sfc' import type { Plugin } from 'vite' +import { createLogger } from 'vite' import type { Options } from '@vitejs/plugin-vue' import _vuePlugin from '@vitejs/plugin-vue' import { TreeShakeTemplatePlugin } from '../src/components/plugins/tree-shake' @@ -66,6 +67,7 @@ async function SFCCompile (name: string, source: string, options: Options, ssr = }) // @ts-expect-error Types are not correct as they are too generic plugin.configResolved!({ + logger: createLogger(), isProduction: options.isProduction, command: 'build', root: process.cwd(), diff --git a/test/basic.test.ts b/test/basic.test.ts index 5a45ebcd4b..c90965d4bf 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -2435,13 +2435,16 @@ describe('component islands', () => { // TODO: resolve dev bug triggered by earlier fetch of /vueuse-head page // https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/core/runtime/nitro/handlers/renderer.ts#L139 result.head.link = result.head.link?.filter(l => typeof l.href !== 'string' || !l.href.includes('SharedComponent')) + if (result.head.link?.[0]?.href) { + result.head.link[0].href = result.head.link[0].href.replace(/scoped=[^?&]+/, 'scoped=xxxxx') + } expect(result.head).toMatchInlineSnapshot(` { "link": [ { "crossorigin": "", - "href": "/_nuxt/components/islands/PureComponent.vue?vue&type=style&index=0&scoped=c0c0cf89&lang.css", + "href": "/_nuxt/components/islands/PureComponent.vue?vue&type=style&index=0&scoped=xxxxx&lang.css", "rel": "stylesheet", }, ],