Cypress fixes
This commit is contained in:
@ -1,15 +1,12 @@
|
||||
{
|
||||
"requestTimeout": 30000,
|
||||
"defaultCommandTimeout": 20000,
|
||||
"reporter": "mocha-junit-reporter",
|
||||
"reporter": "cypress-multi-reporters",
|
||||
"reporterOptions": {
|
||||
"jenkinsMode": true,
|
||||
"rootSuiteTitle": "Cypress",
|
||||
"jenkinsClassnamePrefix": "Cypress.",
|
||||
"mochaFile": "/results/junit/my-test-output-[hash].xml"
|
||||
"configFile": "multi-reporter.json"
|
||||
},
|
||||
"videosFolder": "/results/videos",
|
||||
"screenshotsFolder": "/results/screenshots",
|
||||
"videosFolder": "results/videos",
|
||||
"screenshotsFolder": "results/screenshots",
|
||||
"env": {
|
||||
"swaggerBase": "{{baseUrl}}/api/schema",
|
||||
"RETRIES": 4
|
||||
|
@ -1,13 +1,14 @@
|
||||
{
|
||||
"requestTimeout": 30000,
|
||||
"defaultCommandTimeout": 20000,
|
||||
"reporter": "junit",
|
||||
"reporter": "cypress-multi-reporters",
|
||||
"reporterOptions": {
|
||||
"mochaFile": "results/junit/my-test-output-[hash].xml"
|
||||
"configFile": "multi-reporter.json"
|
||||
},
|
||||
"video": false,
|
||||
"screenshotsFolder": "cypress/results/screenshots",
|
||||
"videos": false,
|
||||
"screenshotsFolder": "results/screenshots",
|
||||
"env": {
|
||||
"swaggerBase": "{{baseUrl}}/api/schema"
|
||||
"swaggerBase": "{{baseUrl}}/api/schema",
|
||||
"RETRIES": 0
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,15 @@
|
||||
|
||||
describe('Basic API checks', () => {
|
||||
it('Should return a valid health payload', function () {
|
||||
cy.wait(2000);
|
||||
cy.task('backendApiGet', {
|
||||
path: '/api/',
|
||||
}).then((data) => {
|
||||
// Check the swagger schema:
|
||||
cy.validateSwaggerSchema('get', '/', data);
|
||||
cy.validateSwaggerSchema('get', 200, '/', data);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should return a valid schema payload', function () {
|
||||
cy.wait(2000);
|
||||
cy.task('backendApiGet', {
|
||||
path: '/api/schema',
|
||||
}).then((data) => {
|
||||
|
@ -26,7 +26,6 @@ describe('Users endpoints', () => {
|
||||
path: '/api/users'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/users', data);
|
||||
expect(typeof data).to.be.equal('array');
|
||||
expect(data.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
@ -13,15 +13,16 @@
|
||||
* Check the swagger schema:
|
||||
*
|
||||
* @param {string} method API Method in swagger doc, "get", "put", "post", "delete"
|
||||
* @param {number} statusCode API status code in swagger doc
|
||||
* @param {string} path Swagger doc endpoint path, exactly as defined in swagger doc
|
||||
* @param {*} data The API response data to check against the swagger schema
|
||||
*/
|
||||
Cypress.Commands.add('validateSwaggerSchema', (method, path, data) => {
|
||||
Cypress.Commands.add('validateSwaggerSchema', (method, statusCode, path, data) => {
|
||||
cy.task('validateSwaggerSchema', {
|
||||
file: Cypress.env('swaggerBase'),
|
||||
endpoint: path,
|
||||
method: method,
|
||||
statusCode: 200,
|
||||
statusCode: statusCode,
|
||||
responseSchema: data,
|
||||
verbose: true
|
||||
}).should('equal', null);
|
||||
@ -32,10 +33,10 @@ Cypress.Commands.add('getToken', () => {
|
||||
cy.task('backendApiPost', {
|
||||
path: '/api/tokens',
|
||||
data: {
|
||||
identity: "admin@example.com",
|
||||
secret: "changeme"
|
||||
identity: 'admin@example.com',
|
||||
secret: 'changeme'
|
||||
}
|
||||
}).then(res => {
|
||||
cy.wrap(res.result.token);
|
||||
cy.wrap(res.token);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user