From 1d0e985922a96143882dfce2cff85ec75de23d37 Mon Sep 17 00:00:00 2001 From: Francisco Hodge Date: Sun, 10 Mar 2019 15:58:22 -0400 Subject: [PATCH] CI: Added dev server testing --- .travis.yml | 3 ++- scripts/start.js | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 00573d26..a26ce8da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,9 @@ install: - npm install -g codecov - npm install script: -- npm run test -- --coverage +- npm run start -- --testMode - npm run demo +- npm run test -- --coverage - codecov after_success: - wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh diff --git a/scripts/start.js b/scripts/start.js index a50f1988..922fe126 100644 --- a/scripts/start.js +++ b/scripts/start.js @@ -75,6 +75,8 @@ checkBrowsers(paths.appPath, isInteractive) // We have not found a port. return; } + const args = process.argv; + const testMode = args[2] === "--testMode"; const protocol = process.env.HTTPS === 'true' ? 'https' : 'http'; const appName = require(paths.appPackageJson).name; const urls = prepareUrls(protocol, HOST, port); @@ -99,6 +101,26 @@ checkBrowsers(paths.appPath, isInteractive) } console.log(chalk.cyan('Starting the development server...\n')); openBrowser(urls.localUrlForBrowser); + + /** + * Handle testMode + */ + if(testMode){ + compiler.plugin('done', (stats) => { + stats = stats.toJson(); + + if (stats.errors && stats.errors.length > 0) { + return; + } + + console.warn("App started in test mode. Closing in 5 seconds."); + let closeTimeout = setTimeout(() => { + clearTimeout(closeTimeout); + devServer.close(); + process.exit(); + }, 5000); + }); + } }); ['SIGINT', 'SIGTERM'].forEach(function(sig) {