Product
Introducing Ruby Support in Socket
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
@serenity-js/rest
Advanced tools
Serenity/JS Screenplay Pattern library for interacting with REST and other HTTP-based services, supporting comprehensive API testing and blended testing scenarios
Serenity/JS is an innovative open-source framework designed to make acceptance and regression testing of complex software systems faster, more collaborative and easier to scale.
⭐️ Get started with Serenity/JS!
👋 Join the Serenity/JS Community!
@serenity-js/rest
module lets your actors interact with and test HTTP REST APIs.
To install this module, as well as axios
HTTP client,
run the following command in your computer terminal:
npm install --save-dev @serenity-js/core @serenity-js/rest @serenity-js/assertions axios
To learn more about Serenity/JS and how to use it on your project, follow the Serenity/JS Getting Started guide.
import { actorCalled } from '@serenity-js/core'
import { CallAnApi, DeleteRequest, GetRequest, LastResponse, PostRequest, Send } from '@serenity-js/rest'
import { Ensure, equals, startsWith } from '@serenity-js/assertions'
const actor = actorCalled('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'))
await actor.attemptsTo(
// no users present in the system
Send.a(GetRequest.to('/users')),
Ensure.that(LastResponse.status(), equals(200)),
Ensure.that(LastResponse.body(), equals([])),
// create a new test user account
Send.a(PostRequest.to('/users').with({
login: 'tester',
password: 'P@ssword1',
}),
Ensure.that(LastResponse.status(), equals(201)),
Ensure.that(LastResponse.header('Location'), startsWith('/users')),
// delete the test user account
Send.a(DeleteRequest.to(LastResponse.header('Location'))),
Ensure.that(LastResponse.status(), equals(200)),
)
New features, tutorials, and demos are coming soon! Follow Serenity/JS on LinkedIn, subscribe to Serenity/JS channel on YouTube and join the Serenity/JS Community Chat to stay up to date! Please also make sure to star ⭐️ Serenity/JS on GitHub to help others discover the framework!
If you appreciate all the effort that goes into making sophisticated tools easy to work with, please support our work and become a Serenity/JS GitHub Sponsor today!
FAQs
Serenity/JS Screenplay Pattern library for interacting with REST and other HTTP-based services, supporting comprehensive API testing and blended testing scenarios
The npm package @serenity-js/rest receives a total of 11,842 weekly downloads. As such, @serenity-js/rest popularity was classified as popular.
We found that @serenity-js/rest demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.