Skip to content

Instantly share code, notes, and snippets.

const test = require('tape')
test('isValidInterface() should take an interface model and an input object and check for type matching, no arrays', function ({ deepEqual, end }) {
const model = {
a: 'string',
b: 'object',
c: 'boolean',
d: 'number'
}
const data = {
const test = require('tape')
test('isValidInterface() should take an interface model and an input object and check for type matching', function ({deepEqual, end}) {
})
defineStep('every element on {string} property has {string}', async function (property, option, table) {
const propFromResponse = get(this.response, property, {})
if (option === 'interface') {
const model = table.rowsHash() // to format a table of 2 columns
const actual = isValidInterface(model, propFromResponse)
const expected = true
deepStrictEqual(actual, expected)
}
})
const { deepStrictEqual } = require('assert')
defineStep('I receive a {int} status code response', async function (status) {
const actual = this.response.statusCode
const expected = status
deepStrictEqual(actual, expected)
/*
It will throw if the response status code is different than 200 for the scenario we are testing.
But you could reuse this step for any expected status
const got = require('got')
defineStep('I make a {string} request to {string}', async function (method, endpoint) {
const headers = this.headers // get headers previously saved to the world store
const uri = new URL(endpoint, 'localhost:3000') // Compose URL with WHATWG URL API
const options = { headers, method } // Create request options
// save the response in the world namespace and parse the body
this.response = await got(uri, options)
this.response.body = JSON.parse(get(this.response, 'body', '{}'))
})
defineStep('request headers', async function (table) {
this.headers = table.rowsHash() // we will format the headers and store it in world namespace for further use
})
defineStep('request headers', async function (table) {})
defineStep('I make a {string} request to {string}', async function (method, endpoint) {})
defineStep('I receive a {int} status code response', async function (status) {})
defineStep('every element on {string} property has {string}', async function (property, option, table) {})
defineStep('{string} property has more than {int} element', async function (property, number) {})
Feature: Stores
As a consumer of the API,
I want to be able to perform CRUD operations on stores endpoints
Scenario: Successfully get a list of stores near me
Given request headers
| content-type | application/json |
When I make a "GET" request to "stores"
Then I receive a 200 status code response
And every element on "body" property has "interface"
| metadata | object |
const test = require('tape')
test('timing test', function (t) {
t.plan(2)
t.equal(typeof Date.now, 'function')
var start = Date.now()
setTimeout(function () {
t.equal(Date.now() - start, 100)
}, 100)
})
const { setWorldConstructor } = require('cucumber')
function CustomWorld () {}
setWorldConstructor(CustomWorld)