diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2020-08-31 06:22:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-31 06:22:39 +0300 |
commit | 85d78179a0bdfab82db8cd0cd58c981685c00b8c (patch) | |
tree | af7653dfdc2b580c51d6f3f868615da4a93417d7 /tests | |
parent | 8a4afd2cd1960c94ce2ef97b0b6572feaac0ceff (diff) |
Allow execution of core and plugin specific JS tests only (#16345)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/javascript/README.md | 4 | ||||
-rw-r--r-- | tests/javascript/index.php | 26 |
2 files changed, 28 insertions, 2 deletions
diff --git a/tests/javascript/README.md b/tests/javascript/README.md index 9e34fdff07..483cce0419 100644 --- a/tests/javascript/README.md +++ b/tests/javascript/README.md @@ -8,3 +8,7 @@ The tests will create a database named `tracker_tests` and store several trackin ## Execute Either open http://piwik.example.com/tests/javascript/ in a browser or execute `phantomjs testrunner.js` on the command line. You can download PhantomJS here: http://phantomjs.org/ + +To execute tests for a specific module use the `module` URL parameter, for example `&module=core`. + +If you are developing multiple tracker plugin and want to only include tests for a specific tracker plugin (like Travis would do) use the URL parameter `plugin` as in `&plugin=MyPluginName`. diff --git a/tests/javascript/index.php b/tests/javascript/index.php index 0753337864..69ae30e95a 100644 --- a/tests/javascript/index.php +++ b/tests/javascript/index.php @@ -8,11 +8,18 @@ $cacheBuster = md5(uniqid(mt_rand(), true)); + // Note: when you want to debug the piwik.js during the tests, you need to set a cache buster that is always the same // between requests so the browser knows it is the same file and know where to breakpoint. //$cacheBuster= 'nocb'; // uncomment to debug $root = dirname(__FILE__) . '/../..'; +$testPluginPath = '*'; +if (!empty($_GET['plugin']) + && ctype_alnum($_GET['plugin']) + && is_dir($root . '/plugins/' . $_GET['plugin'])) { + $testPluginPath = $_GET['plugin']; +} try { $mysql = include_once $root . "/tests/PHPUnit/bootstrap.php"; @@ -92,10 +99,17 @@ testTrackPageViewAsync(); <?php include_once $root . '/core/Filesystem.php'; - $files = \Piwik\Filesystem::globr($root . '/plugins/*/tests/javascript', 'head.php'); + $files = \Piwik\Filesystem::globr($root . '/plugins/'.$testPluginPath.'/tests/javascript', 'head.php'); foreach ($files as $file) { include_once $file; } + if ($testPluginPath !== '*') { + // Travis would always include tag manager + $files = \Piwik\Filesystem::globr($root . '/plugins/TagManager/tests/javascript', 'head.php'); + foreach ($files as $file) { + include_once $file; + } + } ?> <style> .assertSize { @@ -2269,6 +2283,7 @@ function PiwikTest() { equal(Piwik.getAsyncTracker().getTrackerUrl(), asyncTracker.getTrackerUrl(), 'async same getTrackerUrl()'); wait(2000); + var delayedTracker = Piwik.getTracker(); var delayedVisitorId = delayedTracker.getVisitorId(); equal(Piwik.getAsyncTracker().getVisitorId(), delayedVisitorId, 'delayedVisitorId ' + delayedVisitorId + ' should be the same as ' + Piwik.getAsyncTracker().getVisitorId()); @@ -5131,10 +5146,17 @@ function customAddEventListener(element, eventType, eventHandler, useCapture) { <?php include_once $root . '/core/Filesystem.php'; - $files = \Piwik\Filesystem::globr($root . '/plugins/*/tests/javascript', 'index.php'); + $files = \Piwik\Filesystem::globr($root . '/plugins/'.$testPluginPath.'/tests/javascript', 'index.php'); foreach ($files as $file) { include_once $file; } + if ($testPluginPath !== '*') { + // Travis would always include tag manager + $files = \Piwik\Filesystem::globr($root . '/plugins/TagManager/tests/javascript', 'index.php'); + foreach ($files as $file) { + include_once $file; + } + } ?> <div id="jashDiv"> |