@@ -96,29 +96,43 @@ describe("types", () => {
9696 "FAKE RUNTIME" ,
9797 ] . join ( "\n" )
9898 ) ;
99- console . log (
100- [
101- file [ 0 ] ,
102- file [ 1 ] ,
103- "FAKE ENV" ,
104- "// Begin runtime types" ,
105- "FAKE RUNTIME" ,
106- ] . join ( "\n" )
107- ) ;
10899
109100 await helper . run ( `wrangler types` ) ;
110101
111102 const file2 = ( await readFile ( typesPath ) ) . toString ( ) ;
112103
113- expect ( file2 ) . toMatchInlineSnapshot ( `
114- "// Generated by Wrangler by running \`wrangler types\` (hash: e82ba4d7b995dd9ca6fb0332d81f889b)
115- // Runtime types generated with [email protected] 2023-01-01 no_global_navigator,nodejs_compat 116- // eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-empty-object-type
117- interface Env {
118- }
104+ // regenerates env types
105+ expect ( file2 ) . toContain ( "interface Env {" ) ;
106+ // uses cached runtime types
107+ expect ( file2 ) . toContain ( " // Begin runtime types" ) ;
108+ expect ( file2 ) . toContain ( "FAKE RUNTIME" ) ;
109+ } ) ;
119110
120- // Begin runtime types
121- FAKE RUNTIME"
122- ` ) ;
111+ it ( "should prompt you to update types if they've been changed" , async ( ) => {
112+ const helper = new WranglerE2ETestHelper ( ) ;
113+ await helper . seed ( seed ) ;
114+ await helper . run ( `wrangler types` ) ;
115+ seed [ "wrangler.toml" ] = dedent `
116+ name = "test-worker"
117+ main = "src/index.ts"
118+ compatibility_date = "2023-01-01"
119+ compatibility_flags = ["nodejs_compat", "no_global_navigator"]
120+ [vars]
121+ BEEP = "BOOP"
122+ ` ;
123+ await helper . seed ( seed ) ;
124+ const worker = helper . runLongLived ( "wrangler dev" ) ;
125+ await worker . readUntil ( / ❓ I t l o o k s l i k e y o u r t y p e s m i g h t b e o u t o f d a t e ./ ) ;
126+ seed [ "wrangler.toml" ] = dedent `
127+ name = "test-worker"
128+ main = "src/index.ts"
129+ compatibility_date = "2023-01-01"
130+ compatibility_flags = ["nodejs_compat"]
131+ [vars]
132+ BEEP = "BOOP"
133+ ASDf = "ADSfadsf"
134+ ` ;
135+ await helper . seed ( seed ) ;
136+ await worker . readUntil ( / ❓ I t l o o k s l i k e y o u r t y p e s m i g h t b e o u t o f d a t e ./ ) ;
123137 } ) ;
124138} ) ;
0 commit comments