Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2021-04-12 02:34:31 +0300
committerGitHub <noreply@github.com>2021-04-12 02:34:31 +0300
commit4850faed9e3d657321445c15ad6ae35292a02d0e (patch)
tree4ffc75b2963a9f23133de4654f7a40c2c41a27e3 /plugins/TestRunner
parent3b1e602cfc9f814dfccca27a4eac2b3a68a5b044 (diff)
Run JavaScript tests also with node/puppeteer (#17432)
* Run Javascript tests on node / puppeteer * fix js tests for modern browsers supporting sendBeacon * run js tests on phantomjs & on node/puppeteer * updates travis submodule
Diffstat (limited to 'plugins/TestRunner')
-rw-r--r--plugins/TestRunner/Commands/TestsRunJS.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/plugins/TestRunner/Commands/TestsRunJS.php b/plugins/TestRunner/Commands/TestsRunJS.php
new file mode 100644
index 0000000000..af79f9de67
--- /dev/null
+++ b/plugins/TestRunner/Commands/TestsRunJS.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+namespace Piwik\Plugins\TestRunner\Commands;
+
+use Piwik\Plugin\ConsoleCommand;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class TestsRunJS extends ConsoleCommand
+{
+ protected function configure()
+ {
+ $this->setName('tests:run-js');
+ $this->setDescription('Run javascript tests');
+ $this->addOption('matomo-url', null, InputOption::VALUE_REQUIRED, 'Custom matomo url. Defaults to http://localhost');
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $matomoUrl = $input->getOption('matomo-url') ?? 'http://localhost';
+
+ $screenshotTestingDir = PIWIK_INCLUDE_PATH . "/tests/lib/screenshot-testing";
+ $javascriptTestingDir = PIWIK_INCLUDE_PATH . "/tests/javascript";
+
+ $cmdNode = "cd '$javascriptTestingDir' && NODE_PATH='$screenshotTestingDir/node_modules' node testrunnerNode.js '$matomoUrl/tests/javascript/'";
+
+ $output->writeln('Executing command: <info>' . $cmdNode . '</info>');
+ $output->writeln('');
+
+ passthru($cmdNode, $returnCodeNode);
+
+ $cmdPhantom = "phantomjs $javascriptTestingDir/testrunnerPhantom.js '$matomoUrl/tests/javascript/'";
+
+ $output->writeln('');
+ $output->writeln('');
+ $output->writeln('Executing command: <info>' . $cmdPhantom . '</info>');
+ $output->writeln('');
+
+ passthru($cmdPhantom, $returnCodePhantom);
+
+
+ return $returnCodeNode + $returnCodePhantom;
+ }
+}