diff --git a/packages/astro/test/astro-styles-ssr.test.js b/packages/astro/test/astro-styles-ssr.test.js index 2fd87b37a..d07087b26 100644 --- a/packages/astro/test/astro-styles-ssr.test.js +++ b/packages/astro/test/astro-styles-ssr.test.js @@ -101,4 +101,26 @@ StylesSSR('CSS Module support in .astro', async ({ runtime }) => { assert.equal(wrapper.length, 1); }); +StylesSSR('Astro scoped styles', async ({ runtime }) => { + const result = await runtime.load('/'); + const $ = doc(result.contents); + + const el1 = $('#dynamic-class'); + const el2 = $('#dynamic-vis'); + + let scopedClass; + + $('#class') + .attr('class') + .replace(/astro-[A-Za-z0-9-]+/, (match) => { + scopedClass = match; + return match; + }); + + if (!scopedClass) throw new Error(`Astro component missing scoped class`); + + assert.match(el1.attr('class'), `blue ${scopedClass}`); + assert.match(el2.attr('class'), `visible ${scopedClass}`); +}); + StylesSSR.run(); diff --git a/packages/astro/test/fixtures/astro-styles-ssr/src/components/Astro.astro b/packages/astro/test/fixtures/astro-styles-ssr/src/components/Astro.astro new file mode 100644 index 000000000..42967c445 --- /dev/null +++ b/packages/astro/test/fixtures/astro-styles-ssr/src/components/Astro.astro @@ -0,0 +1,18 @@ +--- +let blue = true; +let visible = true; +--- + + + +