Question: How to persist data on Helpers
See original GitHub issueWhat are you trying to achieve?
I’m trying to persist data from one step to another on my own helper.
What I did?
I create a helper that helps me with REST calls (not completed yet have just started working on it)
How my helper looks like
'use strict';
let Request = require('es6-request');
class REST extends Helper {
constructor(config){
super(config);
this.results = {};
}
// add custom methods here
// If you need to access other helpers
// use: this.helpers['helperName']
sendGet(url, params){
return Request.get(url)
.then((body) => {
return body;
});
}
getHttpResult(){
console.log(this.results);
}
}
module.exports = REST;
The configuration for it have nothing special
{
"tests": "./tests/*/rest_test.js",
"timeout": 10000,
"output": "./output",
"helpers": {
"REST": {
"require": "./helpers/rest_helper.js"
}
},
"include": {
"I": "./steps_file.js",
"loginPage": "./pages/loginPage.js"
},
"bootstrap": false,
"mocha": {},
"name": "codeceptjs-poc"
}
I have this on my test
Feature('REST http test');
Scenario('Testing helper for rEST testing', (I) => {
I.sendGet("https://randomuser.me/api/", "whatever");
I.getHttpResult();
});
I just run this using
# node_modules/codeceptjs/bin/codecept.js run
The results of what I have on the console are
➜ codeceptjs-poc git:(master) ✗ node_modules/codeceptjs/bin/codecept.js run
CodeceptJS v0.4.11
Using test root "/Users/atrevino/Projects/codeceptjs-poc"
REST http test --
{}
✓ Testing helper for rEST testing in 440ms
OK | 1 passed // 446ms
So I’m getting an empty object {}
As I said before, I just want to know how to persist data, in this situation it will be the GET response on this.results = {};
. I’m very new to JS also codeceptjs and would like you guys can share your thoughts, suggestions or a way to do it.
Thanks a lot !
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Question: How to persist data on Helpers · Issue #421 - GitHub
I'm trying to persist data from one step to another on my own helper. What I did? I create a helper that helps...
Read more >Data Persistance and/or Data Store? - Scripting Helpers
You need to ask you only one main question which will do in most cases: ... Data Persistence is easier to use as...
Read more >Meteor - How can I pass data between helpers and events for ...
Dependency; Template.tenantsBlock.tenantsList = function() { tenants = []; var property = $properties.findOne({userId: Meteor.userId(), propertyId: Session.get ...
Read more >Persistent storage - web.dev
To request persistent storage for your site's data, call navigator.storage.persist() . It returns a Promise that resolves with a boolean, ...
Read more >Client-side storage - Learn web development | MDN
The Web Storage API is very easy to use — you store simple name/value pairs of data (limited to strings, numbers, etc.) and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can do the following:
If you really need to collect http responses you can do
Once you get it working, please send a Pull Request with it 😃