Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
HTTP Helper Configuration
✓ {
"helpers": {
"HTTP" : {
"require": "codeceptjs-http",
"endpoint": "http://localhost:8080"
}
}
}
✗ import { HTTP } from 'codeceptjs-http';
This package is a CodeceptJS helper. Its functionality is accessed via the `I` object in tests after configuration in `codecept.conf.js` or `codecept.json`, not via direct ES module imports.
I.sendRequest
✓ I.sendRequest('/users', 'POST', { json: { name: 'Alice' } });
✗ import { sendRequest } from 'codeceptjs-http'; sendRequest(...);
The `sendRequest` method is exposed on the global CodeceptJS `I` object after the `codeceptjs-http` helper is correctly configured. It is not directly imported from the package.
I.seeHttpResponseHasValidJsonSchema
✓ I.seeHttpResponseHasValidJsonSchema('userSchema.json');
✗ import { seeHttpResponseHasValidJsonSchema } from 'codeceptjs-http';
The `seeHttpResponseHasValidJsonSchema` method is available on the `I` object within CodeceptJS tests, provided the helper is configured. Schema files are loaded relative to a 'schemas' folder in the CodeceptJS root.
Demonstrates configuring the HTTP helper, sending a POST request to create a user, validating the response schema, then sending a GET request to retrieve the user.
const { I } = inject();
Feature('API Tests');
BeforeSuite(() => {
// Assume a server is running on http://localhost:3000
});
Scenario('Verify user creation and retrieve by ID', async () => {
const userData = { name: 'John Doe', email: 'john.doe@example.com' };
const createResponse = await I.sendRequest('/users', 'POST', {
headers: { 'Content-Type': 'application/json' },
json: userData
});
// Assuming the API returns the created user with an ID
const createdUser = createResponse.body;
I.expect(createResponse.statusCode).to.eql(201);
I.expect(createdUser).to.have.property('id');
I.seeHttpResponseHasValidJsonSchema('schemas/userCreateResponse.json', null, createdUser);
const userId = createdUser.id;
const getResponse = await I.sendRequest(`/users/${userId}`, 'GET');
I.expect(getResponse.statusCode).to.eql(200);
I.expect(getResponse.body.name).to.eql(userData.name);
I.seeHttpResponseHasValidJsonSchema('schemas/userGetResponse.json', null, getResponse.body);
});
// Minimal codecept.conf.js for this quickstart:
// {
// "helpers": {
// "HTTP" : {
// "require": "codeceptjs-http",
// "endpoint": "http://localhost:3000"
// },
// "ChaiWrapper": {
// "require": "codeceptjs-chai"
// }
// }
// }
Errors
Common errors & fixes
TypeError: I.sendRequest is not a function
The `HTTP` helper has not been correctly configured or enabled in the CodeceptJS configuration file (`codecept.conf.js` or `codecept.json`).
fixAdd the `HTTP` helper to your `codecept.conf.js` under the `helpers` section with `require: 'codeceptjs-http'` and ensure CodeceptJS is loading this configuration.
Error: Cannot find module 'then-request'
The package's primary dependency, `then-request`, or other peer dependencies were not installed correctly.
fixRun `npm install codeceptjs-http` or ensure `then-request`, `chai`, and `chai-json-schema` are listed in your project's `package.json` and then run `npm install`.
Error: ENOENT: no such file or directory, open '.../schemas/yourSchema.json'
The specified JSON schema file for `I.seeHttpResponseHasValidJsonSchema` could not be found. The helper expects schemas to be in a `schemas` directory relative to the CodeceptJS project root.
fixCreate a `schemas` directory at your project root and place `yourSchema.json` inside it, or verify the path provided to `seeHttpResponseHasValidJsonSchema` is correct relative to this `schemas` folder.
Audit
Dependencies
then-requestrequiredProvides the underlying HTTP request capabilities.
chairequiredUsed internally for assertions, a common JavaScript assertion library.
chai-json-schemarequiredEnables JSON schema validation for HTTP responses.