I'm trying to learn how to create a simple working step-definition file for my gherkin feature file using the nodejs apickli module. If I try to do a really simple proof of concept connecting to the GitHub API. Here is the API call using curl.
curl -i https://api.github.com/users/marktyers/orgs
This returns a response code of 200.
I have installed cucumber
and apickli
:
npm install --save-dev cucumber apickli
Here is my file structure:
├── index.js
├── package.json
└── test
└── features
├── step_definitions
│ └── myapi.js
└── test.feature
Here is my test.feature
file:
Feature:
As a novice I want to test my BDD framework.
Scenario: Retrieving an empty list should return a 200 code.
Given I set Content-Type header to application-json
When I GET https://api.github.com/users/marktyers/orgs
Then response code should be 200
Here is my myapi.js
file.
'use strict'
const apickli = require('apickli')
module.exports = function() {
// cleanup before every scenario
this.Before(function(scenario, callback) {
this.apickli = new apickli.Apickli('http', 'httpbin.org')
callback()
})
When I run the feature test I get:
Feature:
As a novice I want to test my BDD framework.
Scenario: Retrieving an empty list should return a 200 code.
? Given I set Content-Type header to application-json
? When I GET https://api.github.com/users/marktyers/orgs
? Then response code should be 200
Warnings:
1) Scenario: Retrieving an empty list should return a 200 code. - test/features/todo.feature:5
Step: Given I set Content-Type header to application-json - test/features/todo.feature:6
Message:
Undefined. Implement with the following snippet:
Given('I set Content-Type header to application-json', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
2) Scenario: Retrieving an empty list should return a 200 code. - test/features/todo.feature:5
Step: When I GET https://api.github.com/users/marktyers/orgs - test/features/todo.feature:7
Message:
Undefined. Implement with the following snippet:
When('I GET https://api.github.com/users/marktyers/orgs', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
3) Scenario: Retrieving an empty list should return a 200 code. - test/features/todo.feature:5
Step: Then response code should be 200 - test/features/todo.feature:8
Message:
Undefined. Implement with the following snippet:
Then('response code should be {int}', function (int, callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
1 scenario (1 undefined)
3 steps (3 undefined)
0m00.000s
I know I need to include additional step definitions but where should they go and what should go in them?
via Mark Tyers
No comments:
Post a Comment