Skip to content

Commit

Permalink
fix: Add newAgent() helper
Browse files Browse the repository at this point in the history
This means custom steps can create agents without directly requring
superagent
  • Loading branch information
Philip Mander committed Jan 11, 2019
1 parent ac39918 commit 1ee2a9a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/world-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* [.getOAuthAccessToken(url, credentials)](#module_World..World+getOAuthAccessToken)
* [.replaceVars(val)](#module_World..World+replaceVars)
* [.replaceVariablesInitiator()](#module_World..World+replaceVariablesInitiator)
* [.newAgent()](#module_World..World+newAgent)
* [.getAgentByRole(role)](#module_World..World+getAgentByRole)
* [.setAgentByRole(role, agent)](#module_World..World+setAgentByRole)
* [.getResponseBody(res)](#module_World..World+getResponseBody)
Expand All @@ -38,6 +39,7 @@ State and stateful utilities can be shared between steps using an instance of "W
* [.getOAuthAccessToken(url, credentials)](#module_World..World+getOAuthAccessToken)
* [.replaceVars(val)](#module_World..World+replaceVars)
* [.replaceVariablesInitiator()](#module_World..World+replaceVariablesInitiator)
* [.newAgent()](#module_World..World+newAgent)
* [.getAgentByRole(role)](#module_World..World+getAgentByRole)
* [.setAgentByRole(role, agent)](#module_World..World+setAgentByRole)
* [.getResponseBody(res)](#module_World..World+getResponseBody)
Expand Down Expand Up @@ -118,6 +120,12 @@ environemtn config and previous responses.
Returns Super Agent middleware that replaces placeholders with
variables

**Kind**: instance method of [<code>World</code>](#module_World..World)
<a name="module_World..World+newAgent"></a>

#### world.newAgent()
Creates and gets a new superagent agent

**Kind**: instance method of [<code>World</code>](#module_World..World)
<a name="module_World..World+getAgentByRole"></a>

Expand Down
9 changes: 8 additions & 1 deletion src/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class World {
*/
get currentAgent() {
if (!this._currentAgent) {
this._currentAgent = request.agent();
this._currentAgent = this.newAgent();
}
return this._currentAgent;
}
Expand Down Expand Up @@ -176,6 +176,13 @@ class World {
};
}

/**
* Creates and gets a new superagent agent
*/
newAgent() {
return request.agent();
}

/**
* Get a Superagent agent for a specific authorization role
* @param {string} role The role, such as 'admin'
Expand Down

0 comments on commit 1ee2a9a

Please sign in to comment.