Fix debug web-server on e2e testing
This commit is contained in:
		
							parent
							
								
									e17399c4df
								
							
						
					
					
						commit
						d844440a30
					
				
					 6 changed files with 69 additions and 58 deletions
				
			
		| 
						 | 
				
			
			@ -1,14 +1,24 @@
 | 
			
		|||
var serverUrl = require('./url');
 | 
			
		||||
var http = require('http');
 | 
			
		||||
var url = require('url');
 | 
			
		||||
 | 
			
		||||
const content =
 | 
			
		||||
'<!DOCTYPE html>' +
 | 
			
		||||
'<html lang="en">' +
 | 
			
		||||
  '<body style="width:10000px; height:10000px">' +
 | 
			
		||||
  '</body>' +
 | 
			
		||||
'</html">' ;
 | 
			
		||||
const handleScroll = (req, res) => {
 | 
			
		||||
  res.writeHead(200, {'Content-Type': 'text/html'});
 | 
			
		||||
  res.end('<!DOCTYPEhtml><html lang="en"><body style="width:10000px; height:10000px"></body></html">');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const handle404 = (req, res) => {
 | 
			
		||||
  res.writeHead(404, {'Content-Type': 'text/plain'});
 | 
			
		||||
  res.end('not found')
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
http.createServer(function (req, res) {
 | 
			
		||||
  res.writeHead(200, {'Content-Type': 'text/html'});
 | 
			
		||||
  res.end(content);
 | 
			
		||||
}).listen(11111, '127.0.0.1');
 | 
			
		||||
  let u = url.parse(req.url);
 | 
			
		||||
  if (req.method === 'GET' && u.pathname === '/scroll') {
 | 
			
		||||
    handleScroll(req, res);
 | 
			
		||||
  } else {
 | 
			
		||||
    handle404(req, res);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  console.log(`"${req.method} ${req.url}"`, res.statusCode)
 | 
			
		||||
}).listen(serverUrl.PORT, serverUrl.HOST);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								e2e/web-server/url.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								e2e/web-server/url.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
module.exports = {
 | 
			
		||||
  PORT: 11111,
 | 
			
		||||
  HOST: '127.0.0.1',
 | 
			
		||||
  CLIENT_URL: 'http://127.0.0.1:11111',
 | 
			
		||||
}
 | 
			
		||||
		Reference in a new issue