diff --git a/.circleci/config.yml b/.circleci/config.yml index 901a31e9c1..771fddbe57 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -330,6 +330,7 @@ jobs: name: 'JS Newsletter Editor Tests' command: | mkdir test-results/mocha + ./do compile:js --env production --only-tests ./do t:newsletter-editor test-results/mocha/newsletter_editor_junit.xml - run: name: 'JS Tests' diff --git a/mailpoet/RoboFile.php b/mailpoet/RoboFile.php index 95065e18d1..08add066b9 100644 --- a/mailpoet/RoboFile.php +++ b/mailpoet/RoboFile.php @@ -198,15 +198,17 @@ class RoboFile extends \Robo\Tasks { return $collection->run(); } - public function compileJs($opts = ['env' => null, 'skip-tests' => false]) { + public function compileJs($opts = ['env' => null, 'skip-tests' => false, 'only-tests' => false]) { if (!is_dir('assets/dist/js')) { mkdir('assets/dist/js', 0777, true); } - $this->_exec('rm -rf ' . __DIR__ . '/assets/dist/js/*'); + if (!$opts['only-tests']) { + $this->_exec('rm -rf ' . __DIR__ . '/assets/dist/js/*'); + } $env = ($opts['env']) ? sprintf('./node_modules/.bin/cross-env NODE_ENV="%s"', $opts['env']) : null; - return $this->_exec($env . ' ./node_modules/webpack/bin/webpack.js --env BUILD_TESTS=' . ($opts['skip-tests'] ? 'skip' : 'build')); + return $this->_exec($env . ' ./node_modules/webpack/bin/webpack.js --env BUILD_TESTS=' . ($opts['skip-tests'] ? 'skip' : 'build') . '--env BUILD_ONLY_TESTS=' . ($opts['only-tests'] ? 'true' : 'false')); } public function compileCss($opts = ['env' => null]) { diff --git a/mailpoet/webpack.config.js b/mailpoet/webpack.config.js index 177fc6c2b1..ab3419f80d 100644 --- a/mailpoet/webpack.config.js +++ b/mailpoet/webpack.config.js @@ -265,6 +265,7 @@ const publicConfig = { // Newsletter Editor Tests Config const testConfig = { name: 'test', + mode: PRODUCTION_ENV ? 'production' : 'development', // Add mode directly to testConfig entry: { vendor: 'webpack-vendor-index.jsx', testNewsletterEditor: [ @@ -529,6 +530,12 @@ module.exports = (env) => { if (env && env.BUILD_TESTS === 'build') { configs.push(testConfig); } + + // If only the test build is requested + if (env && env.BUILD_ONLY_TESTS === 'true') { + return [testConfig]; + } + return configs.map((conf) => { const config = Object.assign({}, conf); if (