@@ -22,39 +22,42 @@ function setFeatureFlags(requiredFeatureFlags, value) {
2222 } ) ;
2323}
2424
25- async function runTest ( ssrRendered , Component , testConfig ) {
26- const container = appendTestTarget ( ssrRendered ) ;
27- const selector = container . firstChild . tagName . toLowerCase ( ) ;
28- let target = container . querySelector ( selector ) ;
29-
30- let testResult ;
31- const consoleSpy = spyConsole ( ) ;
32- setFeatureFlags ( testConfig . requiredFeatureFlags , true ) ;
33-
34- if ( testConfig . test ) {
35- const snapshot = testConfig . snapshot ? testConfig . snapshot ( target ) : { } ;
36-
37- const props = testConfig . props || { } ;
38- const clientProps = testConfig . clientProps || props ;
39-
40- LWC . hydrateComponent ( target , Component , clientProps ) ;
41-
42- // let's select again the target, it should be the same elements as in the snapshot
43- target = container . querySelector ( selector ) ;
44- testResult = await testConfig . test ( target , snapshot , consoleSpy . calls ) ;
45- } else if ( testConfig . advancedTest ) {
46- testResult = await testConfig . advancedTest ( target , {
47- Component,
48- hydrateComponent : LWC . hydrateComponent . bind ( LWC ) ,
49- consoleSpy,
50- container,
51- selector,
52- } ) ;
53- }
54-
55- consoleSpy . reset ( ) ;
56-
57- return testResult ;
25+ export function runTest ( configPath , componentPath , ssrRendered , focused ) {
26+ const test = focused ? it . only : it ;
27+ test ( configPath , async ( ) => {
28+ const testConfig = await import ( configPath ) ;
29+ const Component = await import ( componentPath ) ;
30+ const container = appendTestTarget ( ssrRendered ) ;
31+ const selector = container . firstChild . tagName . toLowerCase ( ) ;
32+ let target = container . querySelector ( selector ) ;
33+
34+ let testResult ;
35+ const consoleSpy = spyConsole ( ) ;
36+ setFeatureFlags ( testConfig . requiredFeatureFlags , true ) ;
37+
38+ if ( testConfig . test ) {
39+ const snapshot = testConfig . snapshot ? testConfig . snapshot ( target ) : { } ;
40+
41+ const props = testConfig . props || { } ;
42+ const clientProps = testConfig . clientProps || props ;
43+
44+ LWC . hydrateComponent ( target , Component , clientProps ) ;
45+
46+ // let's select again the target, it should be the same elements as in the snapshot
47+ target = container . querySelector ( selector ) ;
48+ testResult = await testConfig . test ( target , snapshot , consoleSpy . calls ) ;
49+ } else if ( testConfig . advancedTest ) {
50+ testResult = await testConfig . advancedTest ( target , {
51+ Component,
52+ hydrateComponent : LWC . hydrateComponent . bind ( LWC ) ,
53+ consoleSpy,
54+ container,
55+ selector,
56+ } ) ;
57+ }
58+
59+ consoleSpy . reset ( ) ;
60+
61+ return testResult ;
62+ } ) ;
5863}
59-
60- export { runTest } ;
0 commit comments