From f4cc6e45eb8fc5b9fe08a9fc325e5703e1019266 Mon Sep 17 00:00:00 2001 From: robonen Date: Mon, 8 Jun 2026 17:32:29 +0700 Subject: [PATCH] test(vue): avoid CSS-wide keyword as a custom-property value in useCssVar test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Setting a custom property to 'initial' (a CSS-wide keyword) computes to the guaranteed-invalid value, so getComputedStyle returns '' — correct per spec and now implemented by jsdom 29 (the deps bump from jsdom 28). Use a normal token ('start') so the read returns the value. --- .../src/composables/browser/useCssVar/index.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vue/toolkit/src/composables/browser/useCssVar/index.test.ts b/vue/toolkit/src/composables/browser/useCssVar/index.test.ts index 669b512..eaacbe5 100644 --- a/vue/toolkit/src/composables/browser/useCssVar/index.test.ts +++ b/vue/toolkit/src/composables/browser/useCssVar/index.test.ts @@ -172,7 +172,10 @@ describe(useCssVar, () => { it('updates the ref when an observed mutation fires', () => { vi.stubGlobal('MutationObserver', StubMutationObserver); const el = document.createElement('div'); - el.style.setProperty('--y', 'initial'); + // NB: use a normal token, not a CSS-wide keyword like `initial` — per spec + // (and jsdom 29+) a custom property set to `initial` computes to the + // guaranteed-invalid value, so getComputedStyle returns an empty string. + el.style.setProperty('--y', 'start'); document.body.appendChild(el); const scope = effectScope(); @@ -181,7 +184,7 @@ describe(useCssVar, () => { v = useCssVar('--y', el, { observe: true }); }); - expect(v!.value).toBe('initial'); + expect(v!.value).toBe('start'); // Simulate an external change followed by a mutation record. el.style.setProperty('--y', 'external');