@@ -1404,13 +1404,15 @@ describe('test-item-data', () => {
1404
1404
mockedJestTestRun . mockClear ( ) ;
1405
1405
} ) ;
1406
1406
describe . each `
1407
- request | withFile
1408
- ${ { type : 'watch-tests' } } | ${ false }
1409
- ${ { type : 'watch-all-tests' } } | ${ false }
1410
- ${ { type : 'all-tests' } } | ${ false }
1411
- ${ { type : 'by-file' , testFileName : file } } | ${ true }
1412
- ${ { type : 'by-file' , testFileName : 'source.ts' , notTestFile : true } } | ${ false }
1413
- ${ { type : 'by-file-pattern' , testFileNamePattern : file } } | ${ true }
1407
+ request | withFile
1408
+ ${ { type : 'watch-tests' } } | ${ false }
1409
+ ${ { type : 'watch-all-tests' } } | ${ false }
1410
+ ${ { type : 'all-tests' } } | ${ false }
1411
+ ${ { type : 'by-file' , testFileName : file } } | ${ true }
1412
+ ${ { type : 'by-file' , testFileName : 'source.ts' , notTestFile : true } } | ${ false }
1413
+ ${ { type : 'by-file-test' , testFileName : file , testNamePattern : 'whatever' } } | ${ true }
1414
+ ${ { type : 'by-file-pattern' , testFileNamePattern : file } } | ${ true }
1415
+ ${ { type : 'by-file-test-pattern' , testFileNamePattern : file , testNamePattern : 'whatever' } } | ${ true }
1414
1416
` ( 'will create a new run and use it throughout: $request' , ( { request, withFile } ) => {
1415
1417
it ( 'if only reports assertion-update, everything should still work' , ( ) => {
1416
1418
const process : any = { id : 'whatever' , request } ;
@@ -1511,13 +1513,11 @@ describe('test-item-data', () => {
1511
1513
expect ( process . userData . run . write ) . toHaveBeenCalledWith ( 'whatever' , 'error' ) ;
1512
1514
} ) ;
1513
1515
} ) ;
1514
- describe ( 'request not supported' , ( ) => {
1516
+ describe ( 'on request not supported' , ( ) => {
1515
1517
it . each `
1516
1518
request
1517
1519
${ { type : 'not-test' } }
1518
- ${ { type : 'by-file-test' , testFileName : file , testNamePattern : 'whatever' } }
1519
- ${ { type : 'by-file-test-pattern' , testFileNamePattern : file , testNamePattern : 'whatever' } }
1520
- ` ( '$request' , ( { request } ) => {
1520
+ ` ( 'do nothing for request: $request' , ( { request } ) => {
1521
1521
const process = { id : 'whatever' , request } ;
1522
1522
1523
1523
// starting the process
@@ -1557,6 +1557,40 @@ describe('test-item-data', () => {
1557
1557
errors . LONG_RUNNING_TESTS
1558
1558
) ;
1559
1559
} ) ;
1560
+ describe ( 'will catch runtime error and close the run' , ( ) => {
1561
+ let process , jestRun ;
1562
+ beforeEach ( ( ) => {
1563
+ process = mockScheduleProcess ( context ) ;
1564
+ jestRun = createTestRun ( ) ;
1565
+ process . userData = { run : jestRun , testItem : env . testFile } ;
1566
+ } ) ;
1567
+
1568
+ it ( 'when run failed to be created' , ( ) => {
1569
+ // simulate a runtime error
1570
+ jestRun . addProcess = jest . fn ( ( ) => {
1571
+ throw new Error ( 'forced error' ) ;
1572
+ } ) ;
1573
+ // this will not throw error
1574
+ env . onRunEvent ( { type : 'start' , process } ) ;
1575
+
1576
+ expect ( jestRun . started ) . toHaveBeenCalledTimes ( 0 ) ;
1577
+ expect ( jestRun . end ) . toHaveBeenCalledTimes ( 0 ) ;
1578
+ expect ( jestRun . write ) . toHaveBeenCalledTimes ( 0 ) ;
1579
+ } ) ;
1580
+ it ( 'when run is created' , ( ) => {
1581
+ // simulate a runtime error
1582
+ jestRun . started = jest . fn ( ( ) => {
1583
+ throw new Error ( 'forced error' ) ;
1584
+ } ) ;
1585
+
1586
+ // this will not throw error
1587
+ env . onRunEvent ( { type : 'start' , process } ) ;
1588
+
1589
+ expect ( jestRun . started ) . toHaveBeenCalledTimes ( 1 ) ;
1590
+ expect ( jestRun . end ) . toHaveBeenCalledTimes ( 1 ) ;
1591
+ expect ( jestRun . write ) . toHaveBeenCalledTimes ( 1 ) ;
1592
+ } ) ;
1593
+ } ) ;
1560
1594
} ) ;
1561
1595
} ) ;
1562
1596
describe ( 'createTestItem' , ( ) => {
0 commit comments