@@ -9,6 +9,7 @@ import minimist from 'minimist';
9
9
import { execSync } from 'node:child_process' ;
10
10
import fs from 'node:fs' ;
11
11
import path from 'node:path' ;
12
+ import { enforceBaseStylesPlugin } from './web-dev-server.config.js' ;
12
13
13
14
dotenv . config ( ) ;
14
15
@@ -98,6 +99,15 @@ const getAllVisualPackages = () => {
98
99
. filter ( ( dir ) => fs . statSync ( `packages/${ dir } ` ) . isDirectory ( ) && fs . existsSync ( `packages/${ dir } /test/visual` ) ) ;
99
100
} ;
100
101
102
+ /**
103
+ * Get all available packages with visual tests for base styles.
104
+ */
105
+ const getAllBasePackages = ( ) => {
106
+ return fs
107
+ . readdirSync ( 'packages' )
108
+ . filter ( ( dir ) => fs . statSync ( `packages/${ dir } ` ) . isDirectory ( ) && fs . existsSync ( `packages/${ dir } /test/visual/base` ) ) ;
109
+ } ;
110
+
101
111
/**
102
112
* Get packages for running tests.
103
113
*/
@@ -163,7 +173,9 @@ const getUnitTestGroups = (packages) => {
163
173
const getVisualTestGroups = ( packages , theme ) => {
164
174
return packages
165
175
. filter ( ( pkg ) => {
166
- return ! pkg . includes ( theme === 'lumo' ? 'material' : 'lumo' ) ;
176
+ return theme === 'base'
177
+ ? ! pkg . includes ( 'lumo' ) && ! pkg . includes ( 'material' )
178
+ : ! pkg . includes ( theme === 'lumo' ? 'material' : 'lumo' ) ;
167
179
} )
168
180
. map ( ( pkg ) => {
169
181
return {
@@ -218,7 +230,7 @@ const getScreenshotFileName = ({ name, testFile }, type, diff) => {
218
230
folder = 'icons/test/visual/screenshots' ;
219
231
} else {
220
232
const match = testFile . match ( / \/ p a c k a g e s \/ ( .+ ) \. t e s t \. ( j s | t s ) / u) ;
221
- folder = match [ 1 ] . replace ( / ( l u m o | m a t e r i a l ) / u, '$1/screenshots' ) ;
233
+ folder = match [ 1 ] . replace ( / ( b a s e | l u m o | m a t e r i a l ) / u, '$1/screenshots' ) ;
222
234
}
223
235
return path . join ( folder , type , diff ? `${ name } -diff` : name ) ;
224
236
} ;
@@ -263,7 +275,7 @@ const createUnitTestsConfig = (config) => {
263
275
} ;
264
276
265
277
const createVisualTestsConfig = ( theme , browserVersion ) => {
266
- const visualPackages = getAllVisualPackages ( ) ;
278
+ const visualPackages = theme === 'base' ? getAllBasePackages ( ) : getAllVisualPackages ( ) ;
267
279
const packages = getTestPackages ( visualPackages ) ;
268
280
const groups = getVisualTestGroups ( packages , theme ) ;
269
281
@@ -321,7 +333,8 @@ const createVisualTestsConfig = (theme, browserVersion) => {
321
333
failureThresholdType : 'percent' ,
322
334
update : process . env . TEST_ENV === 'update' ,
323
335
} ) ,
324
- ] ,
336
+ theme === 'base' && enforceBaseStylesPlugin ( ) ,
337
+ ] . filter ( Boolean ) ,
325
338
groups,
326
339
testRunnerHtml : getTestRunnerHtml ( theme ) ,
327
340
filterBrowserLogs,
0 commit comments