(protocol)
| 39 | testHttpsConnect(); |
| 40 | |
| 41 | function testWrapper(protocol) { |
| 42 | describe('Rule should get an error in :' + protocol, () => { |
| 43 | let proxyServer; |
| 44 | // let serverInstance; |
| 45 | |
| 46 | beforeAll((done) => { |
| 47 | jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000; |
| 48 | printLog('Start server for rule_deal_error_spec'); |
| 49 | errorInRule = null; |
| 50 | |
| 51 | proxyServer = ProxyServerUtil.proxyServerWithRule(ruleNotDealError); |
| 52 | |
| 53 | setTimeout(() => { |
| 54 | done(); |
| 55 | }, 2000); |
| 56 | }); |
| 57 | |
| 58 | afterAll(() => { |
| 59 | // serverInstance && serverInstance.close(); |
| 60 | proxyServer && proxyServer.close(); |
| 61 | printLog('Close server for rule_deal_error_spec'); |
| 62 | }); |
| 63 | |
| 64 | it('Should get a request error', done => { |
| 65 | const url = protocol + '://not_exist_url.anyproxy.io'; |
| 66 | proxyGet(url) |
| 67 | .then(proxyRes => { |
| 68 | expect(proxyRes.statusCode).toEqual(500); |
| 69 | expect(proxyRes.headers['proxy-error']).toEqual('true'); |
| 70 | expect(errorInRule).not.toBe(null); |
| 71 | done(); |
| 72 | }) |
| 73 | .catch(error => { |
| 74 | console.error('error happened in proxy get: ', error); |
| 75 | done.fail('error happened in proxy get'); |
| 76 | }); |
| 77 | }); |
| 78 | }); |
| 79 | |
| 80 | describe('Rule should return a custom error page in :' + protocol, () => { |
| 81 | let proxyServer; |
| 82 | // let serverInstance; |
| 83 | |
| 84 | beforeAll((done) => { |
| 85 | jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000; |
| 86 | printLog('Start server for rule_deal_error_custom_error_page'); |
| 87 | |
| 88 | proxyServer = ProxyServerUtil.proxyServerWithRule(ruleReturnAnErrorPage); |
| 89 | |
| 90 | setTimeout(() => { |
| 91 | done(); |
| 92 | }, 2000); |
| 93 | }); |
| 94 | |
| 95 | afterAll(() => { |
| 96 | // serverInstance && serverInstance.close(); |
| 97 | proxyServer && proxyServer.close(); |
| 98 | printLog('Close server for rule_deal_error_custom_error_page'); |
no test coverage detected