Jamie Curnow преди 5 години
родител
ревизия
bf2f13443f

+ 2 - 1
test/.gitignore

@@ -1,3 +1,4 @@
 .vscode
 node_modules
-
+results
+cypress/videos

+ 4 - 7
test/cypress/config/ci.json

@@ -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

+ 6 - 5
test/cypress/config/dev.json

@@ -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
 	}
 }

+ 1 - 3
test/cypress/integration/api/Health.spec.js

@@ -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) => {

+ 0 - 1
test/cypress/integration/api/Users.spec.js

@@ -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);
 		});
 	});

+ 6 - 5
test/cypress/support/commands.js

@@ -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: "[email protected]",
-			secret: "changeme"
+			identity: '[email protected]',
+			secret:   'changeme'
 		}
 	}).then(res => {
-		cy.wrap(res.result.token);
+		cy.wrap(res.token);
 	});
 });

+ 9 - 0
test/multi-reporter.json

@@ -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"
+	}
+}

+ 3 - 1
test/package.json

@@ -8,6 +8,7 @@
 		"@jc21/restler": "^3.4.0",
 		"chalk": "^4.1.0",
 		"cypress": "^4.12.1",
+		"cypress-multi-reporters": "^1.4.0",
 		"cypress-plugin-retries": "^1.5.2",
 		"eslint": "^7.6.0",
 		"eslint-plugin-align-assignments": "^1.1.2",
@@ -18,7 +19,8 @@
 		"mocha-junit-reporter": "^2.0.0"
 	},
 	"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": "",
 	"license": "ISC"

Файловите разлики са ограничени, защото са твърде много
+ 332 - 293
test/yarn.lock


Някои файлове не бяха показани, защото твърде много файлове са промени