Registry / testing / cucumberjs-rest-assured

cucumberjs-rest-assured

JSON →
library0.0.21jsnpmunverified

cucumberjs-rest-assured is an API automation testing library for JavaScript/TypeScript that supports Cucumber and Mocha frameworks. Current version 0.0.21 (2023) allows making HTTP requests (GET, POST, PUT, PATCH, DELETE), implicit Chai assertions for JSON responses, JSON path validations, FormData file uploads, and externalizing request/response JSON files. It ships TypeScript types and supports CommonJS, ES6, and ESM. Active development with planned integrations like TestRail.

npm install cucumberjs-rest-assured
INSTALL
IMPORT
SIG · CUCUMBERJS-REST-AS
C
cucumberjs-rest-assured
testingjavascriptv0.0.21
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

makeHttpRequest
import { makeHttpRequest } from 'cucumberjs-rest-assured'
const makeHttpRequest = require('cucumberjs-rest-assured').makeHttpRequest;
Works with CJS require() but ESM import is preferred.
prettyPrintJSON
import { prettyPrintJSON } from 'cucumberjs-rest-assured'
import prettyPrintJSON from 'cucumberjs-rest-assured';
prettyPrintJSON is a named export, not a default export.
makeHttpRequestWithFormData
import { makeHttpRequestWithFormData } from 'cucumberjs-rest-assured'
Used for multipart form data; not available via CJS require in older versions? Currently exported as named.

Shows making a POST request with auth header, printing formatted JSON, and retrieving a JSON path value using the utils.

import { makeHttpRequest, prettyPrintJSON, jsonValidationUtils } from 'cucumberjs-rest-assured'; const authToken = process.env.AUTH_TOKEN ?? ''; (async () => { const headers = JSON.stringify({ Authorization: `Bearer ${authToken}` }); const body = JSON.stringify({ username: 'test', lastname: 'user' }); const response = await makeHttpRequest( 'https://gorest.co.in/public-api/users', JSON.parse(headers), 'POST', body ); const parsedBody = JSON.parse(response.body); console.log(prettyPrintJSON(parsedBody)); // Validate JSON path const value = jsonValidationUtils.getJsonPathValue(parsedBody, 'data[0].username'); console.log(value); })();
Debug
Known issues
gotchaDefault timeout increased to 30,000ms in v0.21; requests may appear slow if not expected.
fix
No fix needed, but you can manually enforce shorter timeouts if necessary.
affects: >=0.0.21
deprecatedPackage is being replaced by 'rest-assured-ts' (see npm). Future updates may focus there.
fix
Consider migrating to 'rest-assured-ts' for continued support.
affects: >=0.0.21
gotchajsonValidationUtils.getJsonPathValue expects parsed object; passing string will cause error.
fix
Always parse JSON body first: JSON.parse(response.body)
affects: >=0.0.1
gotchaHeaders must be passed as an object via JSON.parse(string); passing raw string may break.
fix
Ensure headers are an object: JSON.parse(JSON.stringify({...}))
affects: >=0.0.1
Errors
Common errors & fixes
Cannot find module 'cucumberjs-rest-assured'
Package not installed or typo in import path.
fix
Run 'npm install cucumberjs-rest-assured' and import as specified.
TypeError: response.body is not a string
Response body expected to be a string but might be an object if body was already parsed.
fix
Check response structure; use JSON.stringify if needed.
jsonValidationUtils.getJsonPathValue is not a function
Older version may not export this function or import is wrong.
fix
Update to latest version (>=0.0.21) and ensure named import.
makeHttpRequest is not defined
Using wrong import style (e.g., default import) or CJS require without destructuring.
fix
Use: import { makeHttpRequest } from 'cucumberjs-rest-assured' or const { makeHttpRequest } = require('cucumberjs-rest-assured');
Upgrade
Version history
0.0.21latest on npm
Audit
Dependencies
chaioptionalUsed implicitly for JSON validations
gotrequiredHTTP client used internally
Agent activity
5 hits · last 30 days
node
4
Resources
cucumberjs-rest-assured — npm install cucumberjs-rest-assured · libregistry