[Libreoffice-commits] online.git: 2 commits - cypress_test/package.json cypress_test/plugins cypress_test/README

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 20 16:16:15 UTC 2020


 cypress_test/README           |   54 +++++++++++++++++++++++++++++++++++++-----
 cypress_test/package.json     |    1 
 cypress_test/plugins/index.js |   26 ++++++++++++++------
 3 files changed, 68 insertions(+), 13 deletions(-)

New commits:
commit 12307480999dcde066ca4ce1d9ee2b699d9a906b
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Jul 20 14:23:45 2020 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Mon Jul 20 18:16:04 2020 +0200

    cypress: document used npm packages.
    
    Change-Id: I13d3fd4add5993351e5d5e72a984e4aff522b748
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99072
    Tested-by: Jenkins
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/cypress_test/README b/cypress_test/README
index 9fd00f446..fcf3cc0ed 100644
--- a/cypress_test/README
+++ b/cypress_test/README
@@ -1,9 +1,9 @@
 Cypress based test framework for LibreOffice Online
-====================================================
+===================================================
 
 
 Installation
-------------------
+------------
 
 You need to have run configure with the --enable-cypress option.
 
@@ -17,7 +17,7 @@ https://docs.cypress.io/guides/guides/continuous-integration.html#Dependencies
 
 
 Running tests
-------------------
+-------------
 
 All tests are part of the make check build. So you can
 just execute it from the root folder or under the
@@ -57,7 +57,7 @@ cypress_test/integration_tests/mobile/:
 
 
 Running one specific test
-------------------
+-------------------------
 
 To run one test case of a test suite you can use Mocha's
 'only' feature. Just replace the it(...) function with
@@ -79,7 +79,7 @@ Or open the test suite in the interactive test runner:
     make run-mobile spec=writer/apply_font_spec.js
 
 Openning interactive test runner
-----------------------------------
+--------------------------------
 
 Cypress has an interactive test runner application which
 runs the test in the browser. So you can see the result of
@@ -130,7 +130,7 @@ directory or you should avoid symlinks in the path of the
 build directory.
 
 Code coverage
-------------
+-------------
 
 We use nyc to instrument the code and then cypress code coverage
 plugin is used to generate coverage numbers. This workflow
@@ -148,3 +148,45 @@ doing a clean build is a good idea (e.g. make clean).
 
 See also this link:
 https://docs.cypress.io/guides/tooling/code-coverage.html
+
+Used Packages
+-------------
+
+- cypress:
+    Cypress integration test framework.
+
+- cypress-failed-log:
+    This package makes cypress to dump test logs to the command line
+    when a test fails. You can write things to this log by calling
+    cy.log() in the test code.
+
+- cypress-log-to-output:
+    This one can be used to dump console.error() messages to the command
+    line. To enable this functionality you need to set ENABLE_CONSOLE_LOG
+    environment variable. e.g. `ENABLE_CONSOLE_LOG="1" make check-mobile`.
+
+- cypress-select-tests:
+    We can filter out tests or test suites before execution using this
+    package. Now, it is used to filter out tests based on the core's version.
+    See plugins/blacklists.js.
+
+- cypress-wait-until:
+    Introduces cy.waitUntil() command which can be used as a while loop.
+    We can't write loops in a cypress test otherwise. It's useful when
+    the cypress tools can't be used to wait on something.
+
+- eslint:
+    A JS linter tool for identifying patterns in JavaScript code. We use this
+    to make sure code conventions are met. Run by make check and make run-*.
+
+- eslint-plugin-cypress-rules:
+    This is our own eslint plugin to catch cypress specific patterns in the
+    test code.
+
+- get-port-cli:
+    Used by the build system to find an available port to use as loolwsd's
+    communication port.
+
+- wait-on:
+    Used by the build system to wait on loolwsd server to start before
+    tests are started.
commit 86f2db47a492a24e99bb7a68bc98b81105b7642e
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Jul 20 13:46:15 2020 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Mon Jul 20 18:15:55 2020 +0200

    cypress: add an option to dump only console.error() messages.
    
    With the ENABLE_LOGGING flag we get all errors coming from
    the browser, which is a lot. So I introduce ENABLE_CONSOLE_LOG
    flag now, which dumps only console.error() messages, so we
    can debug the client code easier when we run a test in headless mode.
    
    It will be useful for multi-user tests, where we can't use the
    interactive test runner, because we need to run more users at
    the same time.
    
    Change-Id: Icfa62412b83e37398c54e9ac7b4120d76a87fb92
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99071
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/cypress_test/package.json b/cypress_test/package.json
index b44155035..176b2ea0d 100644
--- a/cypress_test/package.json
+++ b/cypress_test/package.json
@@ -7,6 +7,7 @@
     "cypress": "4.9.0",
     "cypress-failed-log": "2.7.0",
     "cypress-file-upload": "4.0.7",
+    "cypress-log-to-output": "1.0.8",
     "cypress-select-tests": "1.5.7",
     "cypress-wait-until": "1.7.1",
     "eslint": "6.8.0",
diff --git a/cypress_test/plugins/index.js b/cypress_test/plugins/index.js
index eb1837120..a6b1771cb 100644
--- a/cypress_test/plugins/index.js
+++ b/cypress_test/plugins/index.js
@@ -13,13 +13,25 @@ function plugin(on, config) {
 		failed: require('cypress-failed-log/src/failed')()
 	});
 
-	on('before:browser:launch', function(browser, launchOptions) {
-		if (browser.family === 'chromium' && process.env.ENABLE_LOGGING) {
-			launchOptions.args.push('--enable-logging=stderr');
-			launchOptions.args.push('--v=2');
-			return launchOptions;
-		}
-	});
+	if (process.env.ENABLE_CONSOLE_LOG) {
+		require('cypress-log-to-output').install(on, function(type, event) {
+			if (event.level === 'error' || event.type === 'error') {
+				return true;
+			}
+
+			return false;
+		});
+	}
+
+	if (process.env.ENABLE_LOGGING) {
+		on('before:browser:launch', function(browser, launchOptions) {
+			if (browser.family === 'chromium') {
+				launchOptions.args.push('--enable-logging=stderr');
+				launchOptions.args.push('--v=2');
+				return launchOptions;
+			}
+		});
+	}
 
 	on('file:preprocessor', selectTests(config, pickTests));
 


More information about the Libreoffice-commits mailing list