File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -345,10 +345,11 @@ export async function run(): Promise<void> {
345345 }
346346}
347347
348- // Auto-invoke run() only inside the GitHub Actions runner. A negative guard
349- // like `!process.env.VITEST` would silently disable the action in any
350- // workflow that happens to set VITEST (e.g. a step running unit tests in the
351- // same job). GITHUB_ACTIONS is the canonical, runner-set sentinel.
348+ // Auto-invoke run() only inside the GitHub Actions runner.
349+ // GITHUB_ACTIONS is the canonical, runner-set sentinel that is not
350+ // user-controllable. Unit tests override this to '' in vitest.config.ts
351+ // (via test.env) so that module imports during tests do not trigger
352+ // auto-invocation.
352353if ( process . env . GITHUB_ACTIONS === 'true' ) {
353354 run ( ) . catch ( ( error : unknown ) => {
354355 if ( error instanceof Error ) {
Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ export default defineConfig({
2525 exclude : [ 'node_modules' , 'dist' , 'example' ] ,
2626 testTimeout : 10000 ,
2727 hookTimeout : 10000 ,
28+ // Prevent index.ts from auto-invoking run() when tests import it.
29+ // The guard uses GITHUB_ACTIONS === 'true', which is set to 'true'
30+ // in the CI runner environment where unit tests also run.
31+ env : { GITHUB_ACTIONS : '' } ,
2832 } ,
2933 } ,
3034 {
You can’t perform that action at this time.
0 commit comments