Cypress Plugins

Cypress Swagger Validation Plugin

npm (scoped) npm (types) npm (licence) GitHub Release

Do you use Cypress to perform API endpoint testing? Do you have Swagger/Openapi v3 schema? This is the plugin for you.

Your swagger doc will need endpoints with content schema defined.

Usage

describe('Basic API checks', () => {
    it('Should be a valid swagger schema', function () {
        cy.task('validateSwaggerFile', {
            file: './testing/swagger.json',
        }).should('equal', null);
    });

    it('Should return a valid health payload', function () {
        cy.request('/healthz').then($response => {
            // Check the swagger schema:
            cy.task('validateSwaggerSchema', {
                file:           './testing/swagger.json',
                endpoint:       '/healthz',
                method:         'get',
                statusCode:     200,
                responseSchema: $response.body,
                verbose:        true,
            }).should('equal', null);
        });
    });
});

See the Github project for even more documentation.

Cypress JWT Creation

npm (scoped) npm (types) npm (licence) GitHub Release

Create JWT tokens with ease

Cypress Usage

describe('Hit an authenticated endpoint', () => {
    it('Should be able to get a response', async function () {
        cy.request('/users/me').then($response => {

            const token = await cy.task('generateToken', {
                privateKey: '/path/to/private.key',
                issuer:     'cypress-tester',
                algo:       'RS256',
                expires:    '1 day',
                claims:     {
                    capabilities: 'superuser'
                }
            });

            // use token in your requests
        });
    });
});

See the Github project for even more documentation.

Explore Next

DNS router

Other Projects