@@ -145,6 +145,51 @@ test('should list tests with testIdAttribute', async ({ startTestServer, writeFi
145
145
expect ( onProject . use . testIdAttribute ) . toBe ( 'testId' ) ;
146
146
} ) ;
147
147
148
+ test ( 'should serialize exception if config throws error' , async ( { startTestServer, writeFiles } ) => {
149
+ await writeFiles ( {
150
+ 'playwright.config.ts' : `
151
+ throw new Error('Config error');
152
+ ` ,
153
+ } ) ;
154
+
155
+ const testServerConnection = await startTestServer ( ) ;
156
+ const events = await testServerConnection . listFiles ( { } ) ;
157
+ const error = events . report . find ( e => e . method === 'onError' ) . params . error ;
158
+ expect ( error ) . toEqual ( {
159
+ message : expect . stringContaining ( 'Config error' ) ,
160
+ location : {
161
+ file : expect . stringContaining ( 'playwright.config.ts' ) ,
162
+ line : 2 ,
163
+ column : 13 ,
164
+ } ,
165
+ snippet : expect . anything ( ) ,
166
+ stack : expect . stringContaining ( 'Error: Config error' ) ,
167
+ } ) ;
168
+ } ) ;
169
+
170
+
171
+ test ( 'should serialize exception if config has SyntaxError' , async ( { startTestServer, writeFiles } ) => {
172
+ await writeFiles ( {
173
+ 'playwright.config.ts' : `
174
+ Invalid syntax
175
+ ` ,
176
+ } ) ;
177
+
178
+ const testServerConnection = await startTestServer ( ) ;
179
+ const events = await testServerConnection . listFiles ( { } ) ;
180
+ const error = events . report . find ( e => e . method === 'onError' ) . params . error ;
181
+ expect ( error ) . toEqual ( {
182
+ message : expect . stringMatching ( / S y n t a x E r r o r : .* p l a y w r i g h t \. c o n f i g \. t s : M i s s i n g s e m i c o l o n / ) ,
183
+ location : {
184
+ file : expect . stringContaining ( 'playwright.config.ts' ) ,
185
+ line : 2 ,
186
+ column : 13 ,
187
+ } ,
188
+ snippet : expect . anything ( ) ,
189
+ stack : expect . stringMatching ( / S y n t a x E r r o r : .* p l a y w r i g h t \. c o n f i g \. t s : M i s s i n g s e m i c o l o n / ) ,
190
+ } ) ;
191
+ } ) ;
192
+
148
193
test ( 'stdio interception' , async ( { startTestServer, writeFiles } ) => {
149
194
const testServerConnection = await startTestServer ( ) ;
150
195
await testServerConnection . initialize ( { interceptStdio : true } ) ;
0 commit comments