cypress-cucumber-steps
Version:
Cypress Cucumber step definitions
110 lines • 3.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Then_I_see_response_status = Then_I_see_response_status;
exports.Then_I_see_response_body = Then_I_see_response_body;
exports.Then_I_see_response_body_contains = Then_I_see_response_body_contains;
var cypress_cucumber_preprocessor_1 = require("@badeball/cypress-cucumber-preprocessor");
var utils_1 = require("../utils");
/**
* Then I see response status code:
*
* ```gherkin
* Then I see response status {int}
* ```
*
* @example
*
* ```gherkin
* Then I see response status 200
* ```
*
* @remarks
*
* A preceding step like {@link When_I_make_a_request | "When I make a request"} is required. For example:
*
* ```gherkin
* When I make a "POST" request to "/api"
* Then I see response status 200
* ```
*/
function Then_I_see_response_status(code) {
(0, utils_1.getCypressElement)().should(function (response) {
expect(response.status).to.equal(code);
});
}
(0, cypress_cucumber_preprocessor_1.Then)('I see response status {int}', Then_I_see_response_status);
/**
* Then I see response body:
*
* ```gherkin
* Then I see response body {string}
* ```
*
* @example
*
* ```gherkin
* Then I see response body "OK"
* ```
*
* @remarks
*
* A preceding step like {@link When_I_make_a_request | "When I make a request"} is required. For example:
*
* ```gherkin
* When I make a "GET" request to "/user.json"
* Then I see response body '{"id":1,"name":"Mark"}'
* ```
*
* @see
*
* - {@link Then_I_see_response_body_contains | Then I see response body contains}
*/
function Then_I_see_response_body(body) {
(0, utils_1.getCypressElement)().should(function (response) {
if (typeof response.body === 'object') {
expect(response.body).to.deep.equal(JSON.parse(body));
}
else {
expect(response.body).to.equal(body);
}
});
}
(0, cypress_cucumber_preprocessor_1.Then)('I see response body {string}', Then_I_see_response_body);
/**
* Then I see response body contains:
*
* ```gherkin
* Then I see response body contains {string}
* ```
*
* @example
*
* ```gherkin
* Then I see response body contains "OK"
* ```
*
* @remarks
*
* A preceding step like {@link When_I_make_a_request | "When I make a request"} is required. For example:
*
* ```gherkin
* When I make a "GET" request to "/user.json"
* Then I see response body contains '{"name":"Mark"}'
* ```
*
* @see
*
* - {@link Then_I_see_response_body | Then I see response body}
*/
function Then_I_see_response_body_contains(body) {
(0, utils_1.getCypressElement)().should(function (response) {
if (typeof response.body === 'object') {
expect(response.body).to.deep.include(JSON.parse(body));
}
else {
expect(response.body).to.include(body);
}
});
}
(0, cypress_cucumber_preprocessor_1.Then)('I see response body contains {string}', Then_I_see_response_body_contains);
//# sourceMappingURL=response.js.map