I have a simple Then clause that is not covered by Apickli common expressions but not sure where to put the steps. I’ve tried putting it in support/init.js right after the defineSupportCode block and also tried putting it in step_definitions/apickli-gherkin.js but every time it gets to
Then response body path self should not exist
it shows as undefined. Am I missing a export statement somewhere? Here’s my apickli-gherkin.js
module.exports = require("apickli/apickli-gherkin");
const {Then} = require("cucumber");
Then(/^Then response body path (.*) should not exist$/, function(path, callback) {
const assertion = this.apickli.evaluatePathInResponseBody(path);
callbackWithAssertion(callback, assertion);
});
HI @Vicente Lee - create a js file under the “step_definitions” directory and add your expression. For example, a file called check.js
module.exports = function() {
this.Then(/^response body path self should not exist$/ function(callback) {
//your code here
callback();
}
}
I’m still unable to prevent the undefined error. Here’s my feature:
Then response body path self should not exist
I’ve got under features/step_definitions/othersteps.js with this
const {Then} = require("cucumber");
module.exports = function() {
this.Then(/^response body path (.*) should not exist$/, function(path, callback) {
console.log("---------->");
const assertion = this.apickli.evaluatePathInResponseBody(path);
callbackWithAssertion(callback, assertion);
});
}
I am pretty sure the spelling is correct, but for some reason it keeps showing up as undefined.
Can you paste the complete error you are getting ? Still not clear where you are getting “undefined”
It’s not an error, but it’s a warning that causes the “Then” to be skipped.
✔ When I GET /directory/v1/customers # node_modules/apickli/apickli-gherkin.js:91
? Then response body path partner should not exist
Undefined. Implement with the following snippet:
Then('response body path partner should not exist', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
Can you try removing
const {Then} = require("cucumber");
from your js file and try.
Ok, I finally got it to work with this variation.
module.exports = require("apickli/apickli-gherkin");
const {Then} = require("cucumber");
module.exports = Then(/^response body path (.*) should not exist$/, function(path, callback) {
// code here
});
not sure why your variation didn’t work for me.
haa.. looks like a module issue. Can you confirm you have apickli-gherkin.js in your step_definition directory ? If you didn’t, that could be the reason.
However, glad its resolved.
So that’s the strange part. apickli-gherkin.js is in my step_definition directory. My hypothesis is doing module.exports = function … does not immediately expose “Then”.