Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grpc-cucumber-js

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-cucumber-js - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

37

dist/index.js

@@ -182,3 +182,3 @@ 'use strict';

if (error) {
this.responseStatus = grpcJs.status[error.code];
this.responseStatus = error.code;
this.responseError = error;

@@ -325,5 +325,5 @@ callback(error);

var expectedResult = true;
var expectedValue = grpcJs.status[tsEnumUtil.$enum(grpcJs.status).asKeyOrDefault(value)];
var actualValue = tsEnumUtil.$enum(grpcJs.status).asValueOrDefault(this.responseStatus);
var actualResult = expectedValue == expectedValue;
var expectedValue = tsEnumUtil.$enum(grpcJs.status).asKeyOrDefault(value);
var actualValue = tsEnumUtil.$enum(grpcJs.status).asKeyOrDefault(grpcJs.status[this.responseStatus]);
var actualResult = actualValue == expectedValue;
return this.getAssertionResult(expectedResult, actualResult, expectedValue, actualValue);

@@ -359,4 +359,3 @@ };

GprcCucumber.prototype.assertPathIsArray = function (path) {
path = this.replaceVariables(path);
var value = evaluatePath(path, this.getResponseMessage());
var value = this.getResponseMessagePathValue(path);
var success = Array.isArray(value);

@@ -373,3 +372,3 @@ return this.getAssertionResult(true, success, 'array', typeof value);

var actual = '?';
var value = evaluatePath(path, this.getResponseMessage());
var value = this.getResponseMessagePathValue(path);
if (Array.isArray(value)) {

@@ -382,2 +381,26 @@ success = value.length === Number(length);

/**
* Asserts that a path in the response message is a string
*/
GprcCucumber.prototype.assertPathIsString = function (path) {
var value = this.getResponseMessagePathValue(path);
var success = typeof value === 'string';
return this.getAssertionResult(true, success, 'string', typeof value);
};
/**
* Asserts that a path in the response message is a number
*/
GprcCucumber.prototype.assertPathIsNumber = function (path) {
var value = this.getResponseMessagePathValue(path);
var success = typeof value === 'number';
return this.getAssertionResult(true, success, 'number', typeof value);
};
/**
* Asserts that a path in the response message is a boolean
*/
GprcCucumber.prototype.assertPathIsBoolean = function (path) {
var value = this.getResponseMessagePathValue(path);
var success = typeof value === 'boolean';
return this.getAssertionResult(true, success, 'boolean', typeof value);
};
/**
* Asserts that a scenario variable matches a value

@@ -384,0 +407,0 @@ */

@@ -99,2 +99,14 @@ 'use strict';

});
cucumber.Then(/^response message path (.*) should be of type string$/, function (path, callback) {
var assertion = this.grpcucumber.assertPathIsString(path);
this.grpcucumber.callbackWithAssertion(callback, assertion);
});
cucumber.Then(/^response message path (.*) should be of type number$/, function (path, callback) {
var assertion = this.grpcucumber.assertPathIsNumber(path);
this.grpcucumber.callbackWithAssertion(callback, assertion);
});
cucumber.Then(/^response message path (.*) should be of type boolean$/, function (path, callback) {
var assertion = this.grpcucumber.assertPathIsBoolean(path);
this.grpcucumber.callbackWithAssertion(callback, assertion);
});
cucumber.Then(/^value of scenario variable (.*) should be (.*)$/, function (variableName, variableValue, callback) {

@@ -101,0 +113,0 @@ var assertion = this.grpcucumber.assertScenarioVariableValueEqual(variableName, variableValue);

4

package.json
{
"name": "grpc-cucumber-js",
"version": "2.0.1",
"version": "2.1.0",
"author": "Katie Scott <reineskat@gmail.com>",

@@ -20,2 +20,3 @@ "description": "Gherkin framework for gRPC API cucumber-js testing",

"scripts": {
"build": "rollup -c",
"lint": "yarn run eslint '**/*.js'",

@@ -26,2 +27,3 @@ "mock": "node test/mock_target/app.js",

"test:fail": "yarn run cucumber-js --require test/features/step_definitions/*.js --require test/features/support/init.js --tags @fail test/features",
"test:mine": "yarn run cucumber-js --require test/features/step_definitions/*.js --require test/features/support/init.js --tags @mine test/features",
"preci": "rm -fr node_modules",

@@ -28,0 +30,0 @@ "ci": "yarn install --frozen-lockfile"

@@ -12,5 +12,6 @@ [![Build Status](https://travis-ci.org/capitalone/grpc-cucumber-js.svg?branch=master)](https://travis-ci.org/capitalone/grpc-cucumber-js) [![npm version](https://badge.fury.io/js/grpc-cucumber-js.svg)](https://badge.fury.io/js/grpc-cucumber-js)

Install with your usual tool via `yarn add grpc-cucumber-js` or `npm install grpc-cucumber-js`.
Then you need to initialize the library to your gprc API in a Before cucumber event. A good example of a basic set up can be found in [test/features/support/init.js](test/features/support/init.js).
Then you need to initialize the library to your gprc API in a Before cucumber event. A good example of a basic set up can be found in [test/features/support/init.js](test/features/support/init.js).
## Built-in Gherkin Expressions
The following gherkin expressions are available within the framework [source/grpcucumber-steps.js](source/grpcucumber-steps.js):

@@ -39,2 +40,5 @@

response message path (.*) should not be (((?!of type).+))
response message path (.*) should be of type string
response message path (.*) should be of type number
response message path (.*) should be of type boolean
response message path (.*) should be of type array

@@ -57,6 +61,6 @@ response message path (.*) should be of type array with length (.*)

this.grpcucumber = new grpcucumber.grpcucumber(
'localhost:8080',
PROTO_PATH,
'Greeter',
credentials,
'localhost:8080',
PROTO_PATH,
'Greeter',
credentials,
{ variableDelimiter: '{}' }

@@ -67,10 +71,9 @@ );

## Quick commands
| Function | Command |
| :------------------------- | :--------------- |
| Run mock server | `yarn run mock` |
| Run tests (run mock first) | `yarn run test` |
| Run lint | `yarn run lint` |
| Function | Command |
| :------------------------- | :-------------- |
| Run mock server | `yarn run mock` |
| Run tests (run mock first) | `yarn run test` |
| Run lint | `yarn run lint` |

@@ -77,0 +80,0 @@ # Contributing to grpc-cucumber-js

@@ -191,3 +191,3 @@ import fs from 'fs';

if (error) {
this.responseStatus = status[error.code];
this.responseStatus = error.code;
this.responseError = error;

@@ -387,8 +387,8 @@ callback(error);

const expectedValue = status[$enum(status).asKeyOrDefault(value)];
const actualValue = $enum(status).asValueOrDefault(
this.responseStatus,
const expectedValue = $enum(status).asKeyOrDefault(value);
const actualValue = $enum(status).asKeyOrDefault(
status[this.responseStatus],
);
let actualResult = expectedValue == expectedValue;
let actualResult = actualValue == expectedValue;

@@ -442,4 +442,3 @@ return this.getAssertionResult(

assertPathIsArray(path: string) {
path = this.replaceVariables(path);
const value = evaluatePath(path, this.getResponseMessage());
const value = this.getResponseMessagePathValue(path);
const success = Array.isArray(value);

@@ -462,3 +461,3 @@ return this.getAssertionResult(

let actual = '?';
const value = evaluatePath(path, this.getResponseMessage());
const value = this.getResponseMessagePathValue(path);
if (Array.isArray(value)) {

@@ -473,2 +472,44 @@ success = value.length === Number(length);

/**
* Asserts that a path in the response message is a string
*/
assertPathIsString(path: string) {
const value = this.getResponseMessagePathValue(path);
const success = typeof value === 'string';
return this.getAssertionResult(
true,
success,
'string',
typeof value,
);
}
/**
* Asserts that a path in the response message is a number
*/
assertPathIsNumber(path: string) {
const value = this.getResponseMessagePathValue(path);
const success = typeof value === 'number';
return this.getAssertionResult(
true,
success,
'number',
typeof value,
);
}
/**
* Asserts that a path in the response message is a boolean
*/
assertPathIsBoolean(path: string) {
const value = this.getResponseMessagePathValue(path);
const success = typeof value === 'boolean';
return this.getAssertionResult(
true,
success,
'boolean',
typeof value,
);
}
/**
* Asserts that a scenario variable matches a value

@@ -475,0 +516,0 @@ */

@@ -196,2 +196,26 @@ /*

Then(
/^response message path (.*) should be of type string$/,
function (path: any, callback: any) {
let assertion = this.grpcucumber.assertPathIsString(path);
this.grpcucumber.callbackWithAssertion(callback, assertion);
},
);
Then(
/^response message path (.*) should be of type number$/,
function (path: any, callback: any) {
let assertion = this.grpcucumber.assertPathIsNumber(path);
this.grpcucumber.callbackWithAssertion(callback, assertion);
},
);
Then(
/^response message path (.*) should be of type boolean$/,
function (path: any, callback: any) {
let assertion = this.grpcucumber.assertPathIsBoolean(path);
this.grpcucumber.callbackWithAssertion(callback, assertion);
},
);
Then(
/^value of scenario variable (.*) should be (.*)$/,

@@ -198,0 +222,0 @@ function (variableName: any, variableValue: any, callback: any) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc