File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 11const assert = require ( "assert" ) ;
22const request = require ( "supertest" ) ;
33const server = require ( "../src/server" ) ;
4+ const {
5+ promises : { readFile }
6+ } = require ( "fs" ) ;
7+ const path = require ( "path" ) ;
48
59describe ( "server" , ( ) => {
610 // 3.1
@@ -38,6 +42,20 @@ describe("server", () => {
3842 ) ;
3943 } ) ;
4044 } ) ;
45+ // 6.5
46+ it ( "should load the dotenv config" , async ( ) => {
47+ const serverFilePath = path . join ( process . cwd ( ) , "src" , "server.js" ) ;
48+ const serverFile = await readFile ( serverFilePath , "utf8" ) ;
49+ const lines = serverFile . split ( "/n" ) ;
50+ const firstLines = lines . slice ( 0 , 5 ) ;
51+ let match = false ;
52+ for ( const line of firstLines ) {
53+ if ( line . match ( / r e q u i r e .+ d o t e n v .+ \. c o n f i g ( ) / ) ) {
54+ match = true ;
55+ }
56+ }
57+ assert . ok ( match , "should load dotenv config at the top of the file" ) ;
58+ } ) ;
4159 after ( ( ) => {
4260 server . close ( ) ;
4361 } ) ;
You can’t perform that action at this time.
0 commit comments