I would like to create a scenario similar to this:
Scenario: initialize new Singleton
When an unmatched identity is received for the first time
Then create a new tin record
And establish a new bronze record
And generate a new gold record
This scenario should be connected to steps like these:
defineSupportCode(function ({ Before, Given, Then, When }) {
var expect = require('chai').expect;
var chanceGenerator = require('./helpers/chanceGenerator')
var request = require('./helpers/requestGenerator')
let identMap;
// reset identMap before each scenario
Before(function () {
identMap = [];
});
// more code...
The challenge I am facing is that I am unable to perform any actions within the Then callback. This is where I want to verify if the response contains the correct data.
Here are some relevant excerpts from the helper files:
// functions for handling POST and GET requests for identity records
var pubPostIdentity = function (ident, callback) {
// code here...
}
var pubGetIdentity = function (ident, callback) {
// code here...
}
We are considering rewriting the feature with a different step definition structure to avoid the callback issue. For example:
Scenario: initialize new Singleton
When receiving an unmatchable 'TIN_RECORD'
Then ensure successful creation of the Identity Record
When retrieving the Identity Record for 'tin'
Then create a new 'tin'
// more steps...
While this revision may resolve the callback problem, it compromises the readability and clarity of the feature. It may not be easily understood by non-technical stakeholders.
So my question is, is the initial summary feature poorly written? Am I expecting too much from the step definitions, or is there a mistake in my JavaScript implementation?