Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: TestAgent not inheriting Agent properties #834

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const Test = require('./test.js');
function TestAgent(app, options = {}) {
if (!(this instanceof TestAgent)) return new TestAgent(app, options);

Agent.call(this, options);
const agent = new Agent(options);
Copy link
Author

@Bruception Bruception Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this commit to change from functions to classes breaks this behavior.
ladjs/superagent@fca95a3

The apply hook in the Proxy seems to discard the this reference and so it is not being binded.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks promising (and explanation makes sense) 👀

Object.assign(this, agent);

this._options = options;

if (typeof app === 'function') {
Expand Down