MCPcopy
hub / github.com/vitejs/vite / sassModuleTests

Function sassModuleTests

playground/css/__tests__/sass-tests.ts:81–117  ·  view source on GitHub ↗
(enableHmrTests = false)

Source from the content-addressed store, hash-verified

79}
80
81export const sassModuleTests = (enableHmrTests = false) => {
82 test('sass modules composes/from path resolving', async () => {
83 const imported = await page.$('.path-resolved-modules-sass')
84 expect(await getColor(imported)).toBe('orangered')
85
86 // check if the generated CSS module class name is indeed using the
87 // format specified in vite.config.js
88 expect(await imported.getAttribute('class')).toMatch(
89 /.composed-module__apply-color___[\w-]{5}/,
90 )
91
92 expect(await imported.getAttribute('class')).toMatch(
93 /.composes-path-resolving-module__path-resolving-sass___[\w-]{5}/,
94 )
95
96 // @todo HMR is not working on this situation.
97 // editFile('composed.module.scss', (code) =>
98 // code.replace('color: orangered', 'color: red')
99 // )
100 // await expect.poll(() => getColor(imported)).toMatch('red')
101 })
102
103 test('css modules w/ sass', async () => {
104 const imported = await page.$('.modules-sass')
105 expect(await getColor(imported)).toBe('orangered')
106 expect(await imported.getAttribute('class')).toMatch(
107 /.mod-module__apply-color___[\w-]{5}/,
108 )
109
110 if (isBuild) return
111
112 editFile('mod.module.scss', (code) =>
113 code.replace('color: orangered', 'color: blue'),
114 )
115 await expect.poll(() => getColor(imported)).toBe('blue')
116 })
117}
118
119export const sassOtherTests = () => {
120 test('@import dependency w/ sass entry', async () => {

Callers 1

tests.tsFile · 0.90

Calls 3

testFunction · 0.90
getColorFunction · 0.85
editFileFunction · 0.50

Tested by

no test coverage detected