chaijs / chai-http

HTTP Response assertions for the Chai Assertion Library.
http://chaijs.com/plugins/chai-http
634 stars 113 forks source link

Superagent-proxy integration Failed #291

Open jovmilan95 opened 3 years ago

jovmilan95 commented 3 years ago

const data = require("./test_data"); const faker = require("faker"); const chai = require("chai"); const chaiHttp = require("chai-http"); const jwtDecode = require("jwt-decode"); const dayjs = require("dayjs"); const sleep = require('sleep');

const server = process.env.JETWEB_TEST_INSTANCE; const should = chai.should();

chai.use(chaiHttp); chai.request.Request = chai.request.Test; require('superagent-proxy')(chai.request.Test);

let sessionCookie = "";

describe("Users", () => { describe("Shows the UI of the application", () => { it("it should get home API url", done => { chai .request(server) .get("/app") .proxy("http://127.0.0.1:9999") .end((err, res) => { res.should.have.status(200, res.text); // console.log(res) done(); }); }); });

Got error

D:\jetweb\frontend\node_modules\superagent-proxy\index.js:92 if (desc.get == getUrl && desc.set == setUrl) return; // already patched ^

TypeError: Cannot read property 'get' of undefined at setupUrl (D:\jetweb\frontend\node_modules\superagent-proxy\index.js:92:12) at Function.proxy (D:\jetweb\frontend\node_modules\superagent-proxy\index.js:68:3) at setup (D:\jetweb\frontend\node_modules\superagent-proxy\index.js:50:18) at Object. (D:\jetweb\frontend\tests\api\users.js:14:28) at Module._compile (node:internal/modules/cjs/loader:1108:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10) at Module.load (node:internal/modules/cjs/loader:973:32) at Function.Module._load (node:internal/modules/cjs/loader:813:14) at Module.require (node:internal/modules/cjs/loader:997:19) at require (node:internal/modules/cjs/helpers:92:18)

No way from this issue was helpful Any suggestions?

├── chai-http@4.3.0 ├── chai@4.3.4 ├── superagent-proxy@1.0.2