@@ -1459,6 +1459,82 @@ describe('modules that fail to load', () => {
14591459 ` )
14601460 } )
14611461
1462+ test ( 'a test that imports a deleted file runs and reports the error' , async ( ) => {
1463+ const { results } = await runInlineTests (
1464+ {
1465+ 'vitest.config.js' : { resolve : { alias : { '@' : '/src' } } } ,
1466+ 'src/other.js' : 'export {}' ,
1467+ 'a.test.js' : testFile ( 'a' , `import './src/helper.js'` ) ,
1468+ 'b.test.js' : testFile ( 'b' , `import '@/helper'` ) ,
1469+ 'c.test.js' : testFile ( 'c' , `import './src/other.js'` ) ,
1470+ } ,
1471+ { related : [ 'src/helper.js' ] } ,
1472+ )
1473+
1474+ expect ( moduleStates ( results ) ) . toMatchInlineSnapshot ( `
1475+ [
1476+ [
1477+ "a.test.js",
1478+ "failed",
1479+ ],
1480+ [
1481+ "b.test.js",
1482+ "failed",
1483+ ],
1484+ ]
1485+ ` )
1486+ } )
1487+
1488+ test ( 'a test that catches a dynamic import of a deleted file does not run' , async ( ) => {
1489+ const { results } = await runInlineTests (
1490+ {
1491+ 'src/changed.js' : 'export {}' ,
1492+ 'a.test.js' : `
1493+ import { test } from 'vitest'
1494+ test('a', async () => {
1495+ await import('./src/helper.js').catch(() => {})
1496+ })
1497+ ` ,
1498+ 'b.test.js' : testFile ( 'b' , `import './src/changed.js'` ) ,
1499+ } ,
1500+ { related : [ 'src/helper.js' , 'src/changed.js' ] } ,
1501+ )
1502+
1503+ expect ( moduleStates ( results ) ) . toMatchInlineSnapshot ( `
1504+ [
1505+ [
1506+ "b.test.js",
1507+ "passed",
1508+ ],
1509+ ]
1510+ ` )
1511+ } )
1512+
1513+ test ( 'a setup file that imports a deleted file runs every test' , async ( ) => {
1514+ const { results } = await runInlineTests (
1515+ {
1516+ 'vitest.config.js' : { test : { setupFiles : [ './setup.js' ] } } ,
1517+ 'setup.js' : `import './src/helper.js'` ,
1518+ 'a.test.js' : testFile ( 'a' ) ,
1519+ 'b.test.js' : testFile ( 'b' ) ,
1520+ } ,
1521+ { related : [ 'src/helper.js' ] } ,
1522+ )
1523+
1524+ expect ( moduleStates ( results ) ) . toMatchInlineSnapshot ( `
1525+ [
1526+ [
1527+ "a.test.js",
1528+ "failed",
1529+ ],
1530+ [
1531+ "b.test.js",
1532+ "failed",
1533+ ],
1534+ ]
1535+ ` )
1536+ } )
1537+
14621538 function moduleStates ( modules : TestModule [ ] ) {
14631539 return modules
14641540 . map ( ( testModule ) => [ testModule . relativeModuleId , testModule . state ( ) ] )
0 commit comments