@@ -154,48 +154,20 @@ describe("proxy", () => {
154154 } )
155155} )
156156
157+ // NOTE@jsjoeio
158+ // Both this test suite and the one above it are very similar
159+ // The main difference is this one uses http and node-fetch
160+ // and specifically tests the proxy in isolation vs. using
161+ // the httpserver abstraction we've built.
162+ //
163+ // Leaving this as a separate test suite for now because
164+ // we may consider refactoring the httpserver abstraction
165+ // in the future.
166+ //
167+ // If you're writing a test specifically for code in
168+ // src/node/proxy.ts, you should probably add it to
169+ // this test suite.
157170describe ( "proxy (standalone)" , ( ) => {
158- const testServer = new httpserver . HttpServer ( )
159- const proxyServer = proxy
160- let expressServer : express . Express
161-
162- beforeAll ( async ( ) => {
163- await testServer . listen ( ( req , res ) => {
164- proxyServer . web ( req , res , { target : `http://localhost:${ testServer . port ( ) } ` } )
165- expressServer ( req , res )
166- } )
167- } )
168-
169- afterAll ( async ( ) => {
170- await testServer . close ( )
171- await proxyServer . close ( )
172- } )
173-
174- beforeEach ( ( ) => {
175- expressServer = express . default ( )
176- } )
177-
178- it ( "should handle errors" , async ( ) => {
179- // Notes: I think I'm close
180- // but I think this code is testing that our fake expressServer
181- // is returning a 500
182- // not the proxy
183- expressServer . post ( "/error" , ( req , res ) => {
184- throw new Error ( "BROKEN" )
185- } )
186-
187- const resp = await testServer . fetch ( `/error` , {
188- method : "post" ,
189- body : JSON . stringify ( "coder is the best" ) ,
190- headers : {
191- "Content-Type" : "application/json" ,
192- } ,
193- } )
194- expect ( resp . status ) . toBe ( 500 )
195- } )
196- } )
197-
198- describe ( "code-server proxy" , ( ) => {
199171 const PORT = 9003
200172 const PROXY_PORT = 8003
201173 const URL = `http://localhost:${ PORT } `
0 commit comments