1- import { describe , it , expect , beforeEach , afterEach , vi } from 'vitest'
1+ import { describe , it , expect , beforeEach , afterEach } from 'vitest'
22import { isBuildTime } from '../../src/runtime/server/utils/build-time'
33
44describe ( 'Build-time Detection' , ( ) => {
@@ -44,7 +44,7 @@ describe('Build-time Detection', () => {
4444 delete process . env . NUXT_ENV
4545 delete process . env . npm_lifecycle_event
4646 process . argv = [ 'node' , 'server.js' ]
47-
47+
4848 expect ( isBuildTime ( ) ) . toBe ( false )
4949 } )
5050 } )
@@ -53,10 +53,10 @@ describe('Build-time Detection', () => {
5353 it ( 'should prevent database connections during build time' , async ( ) => {
5454 // Set build-time environment
5555 process . env . NITRO_PRESET = 'nitro-prerender'
56-
56+
5757 // Import the db module
5858 const { useDb } = await import ( '../../src/runtime/server/utils/db' )
59-
59+
6060 const mockOptions = {
6161 connector : { name : 'sqlite' as const , options : { path : './test.db' } } ,
6262 tables : { migrations : 'migrations' , users : 'users' , personalAccessTokens : 'tokens' , passwordResetTokens : 'reset_tokens' } ,
@@ -74,7 +74,7 @@ describe('Build-time Detection', () => {
7474 } ,
7575 hardDelete : false
7676 }
77-
77+
7878 // Should throw an error indicating build-time detection
7979 await expect ( useDb ( mockOptions ) )
8080 . rejects
@@ -86,22 +86,22 @@ describe('Build-time Detection', () => {
8686 it ( 'should detect production builds with prerender flag' , ( ) => {
8787 process . env . NODE_ENV = 'production'
8888 process . argv = [ 'node' , 'nuxt' , 'build' , '--prerender' ]
89-
89+
9090 expect ( isBuildTime ( ) ) . toBe ( true )
9191 } )
9292
9393 it ( 'should detect generate command' , ( ) => {
9494 process . argv = [ 'node' , 'nuxt' , 'generate' ]
95-
95+
9696 expect ( isBuildTime ( ) ) . toBe ( true )
9797 } )
9898
9999 it ( 'should not detect regular production server' , ( ) => {
100100 process . env . NODE_ENV = 'production'
101101 process . argv = [ 'node' , 'server.js' ]
102102 delete process . env . npm_lifecycle_event
103-
103+
104104 expect ( isBuildTime ( ) ) . toBe ( false )
105105 } )
106106 } )
107- } )
107+ } )
0 commit comments