Cypress fixes
This commit is contained in:
parent
9ce4c3fe2f
commit
bf2f13443f
3
test/.gitignore
vendored
3
test/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.vscode
|
.vscode
|
||||||
node_modules
|
node_modules
|
||||||
|
results
|
||||||
|
cypress/videos
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
{
|
{
|
||||||
"requestTimeout": 30000,
|
"requestTimeout": 30000,
|
||||||
"defaultCommandTimeout": 20000,
|
"defaultCommandTimeout": 20000,
|
||||||
"reporter": "mocha-junit-reporter",
|
"reporter": "cypress-multi-reporters",
|
||||||
"reporterOptions": {
|
"reporterOptions": {
|
||||||
"jenkinsMode": true,
|
"configFile": "multi-reporter.json"
|
||||||
"rootSuiteTitle": "Cypress",
|
|
||||||
"jenkinsClassnamePrefix": "Cypress.",
|
|
||||||
"mochaFile": "/results/junit/my-test-output-[hash].xml"
|
|
||||||
},
|
},
|
||||||
"videosFolder": "/results/videos",
|
"videosFolder": "results/videos",
|
||||||
"screenshotsFolder": "/results/screenshots",
|
"screenshotsFolder": "results/screenshots",
|
||||||
"env": {
|
"env": {
|
||||||
"swaggerBase": "{{baseUrl}}/api/schema",
|
"swaggerBase": "{{baseUrl}}/api/schema",
|
||||||
"RETRIES": 4
|
"RETRIES": 4
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"requestTimeout": 30000,
|
"requestTimeout": 30000,
|
||||||
"defaultCommandTimeout": 20000,
|
"defaultCommandTimeout": 20000,
|
||||||
"reporter": "junit",
|
"reporter": "cypress-multi-reporters",
|
||||||
"reporterOptions": {
|
"reporterOptions": {
|
||||||
"mochaFile": "results/junit/my-test-output-[hash].xml"
|
"configFile": "multi-reporter.json"
|
||||||
},
|
},
|
||||||
"video": false,
|
"videos": false,
|
||||||
"screenshotsFolder": "cypress/results/screenshots",
|
"screenshotsFolder": "results/screenshots",
|
||||||
"env": {
|
"env": {
|
||||||
"swaggerBase": "{{baseUrl}}/api/schema"
|
"swaggerBase": "{{baseUrl}}/api/schema",
|
||||||
|
"RETRIES": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,15 @@
|
|||||||
|
|
||||||
describe('Basic API checks', () => {
|
describe('Basic API checks', () => {
|
||||||
it('Should return a valid health payload', function () {
|
it('Should return a valid health payload', function () {
|
||||||
cy.wait(2000);
|
|
||||||
cy.task('backendApiGet', {
|
cy.task('backendApiGet', {
|
||||||
path: '/api/',
|
path: '/api/',
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
// Check the swagger schema:
|
// Check the swagger schema:
|
||||||
cy.validateSwaggerSchema('get', '/', data);
|
cy.validateSwaggerSchema('get', 200, '/', data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should return a valid schema payload', function () {
|
it('Should return a valid schema payload', function () {
|
||||||
cy.wait(2000);
|
|
||||||
cy.task('backendApiGet', {
|
cy.task('backendApiGet', {
|
||||||
path: '/api/schema',
|
path: '/api/schema',
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
|
@ -26,7 +26,6 @@ describe('Users endpoints', () => {
|
|||||||
path: '/api/users'
|
path: '/api/users'
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
cy.validateSwaggerSchema('get', 200, '/users', data);
|
cy.validateSwaggerSchema('get', 200, '/users', data);
|
||||||
expect(typeof data).to.be.equal('array');
|
|
||||||
expect(data.length).to.be.greaterThan(0);
|
expect(data.length).to.be.greaterThan(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -13,15 +13,16 @@
|
|||||||
* Check the swagger schema:
|
* Check the swagger schema:
|
||||||
*
|
*
|
||||||
* @param {string} method API Method in swagger doc, "get", "put", "post", "delete"
|
* @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 {string} path Swagger doc endpoint path, exactly as defined in swagger doc
|
||||||
* @param {*} data The API response data to check against the swagger schema
|
* @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', {
|
cy.task('validateSwaggerSchema', {
|
||||||
file: Cypress.env('swaggerBase'),
|
file: Cypress.env('swaggerBase'),
|
||||||
endpoint: path,
|
endpoint: path,
|
||||||
method: method,
|
method: method,
|
||||||
statusCode: 200,
|
statusCode: statusCode,
|
||||||
responseSchema: data,
|
responseSchema: data,
|
||||||
verbose: true
|
verbose: true
|
||||||
}).should('equal', null);
|
}).should('equal', null);
|
||||||
@ -32,10 +33,10 @@ Cypress.Commands.add('getToken', () => {
|
|||||||
cy.task('backendApiPost', {
|
cy.task('backendApiPost', {
|
||||||
path: '/api/tokens',
|
path: '/api/tokens',
|
||||||
data: {
|
data: {
|
||||||
identity: "admin@example.com",
|
identity: 'admin@example.com',
|
||||||
secret: "changeme"
|
secret: 'changeme'
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
cy.wrap(res.result.token);
|
cy.wrap(res.token);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
9
test/multi-reporter.json
Normal file
9
test/multi-reporter.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"reporterEnabled": "spec, mocha-junit-reporter",
|
||||||
|
"mochaJunitReporterReporterOptions": {
|
||||||
|
"jenkinsMode": true,
|
||||||
|
"rootSuiteTitle": "Cypress.npm",
|
||||||
|
"jenkinsClassnamePrefix": "Cypress.npm.",
|
||||||
|
"mochaFile": "results/junit/cypress.npm.[hash].xml"
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@
|
|||||||
"@jc21/restler": "^3.4.0",
|
"@jc21/restler": "^3.4.0",
|
||||||
"chalk": "^4.1.0",
|
"chalk": "^4.1.0",
|
||||||
"cypress": "^4.12.1",
|
"cypress": "^4.12.1",
|
||||||
|
"cypress-multi-reporters": "^1.4.0",
|
||||||
"cypress-plugin-retries": "^1.5.2",
|
"cypress-plugin-retries": "^1.5.2",
|
||||||
"eslint": "^7.6.0",
|
"eslint": "^7.6.0",
|
||||||
"eslint-plugin-align-assignments": "^1.1.2",
|
"eslint-plugin-align-assignments": "^1.1.2",
|
||||||
@ -18,7 +19,8 @@
|
|||||||
"mocha-junit-reporter": "^2.0.0"
|
"mocha-junit-reporter": "^2.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"cypress": "cypress open --config-file=cypress/config/dev.json --config baseUrl=http://127.0.0.1:3081"
|
"cypress": "cypress open --config-file=cypress/config/dev.json --config baseUrl=${BASE_URL:-http://127.0.0.1:3081}",
|
||||||
|
"cypress:headless": "cypress run --config-file=cypress/config/dev.json --config baseUrl=${BASE_URL:-http://127.0.0.1:3081}"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
|
1233
test/yarn.lock
1233
test/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user