Skip to content

Commit

Permalink
Merge pull request #141 from stone-payments/feature/night-watch-script
Browse files Browse the repository at this point in the history
Update nightwatch script
  • Loading branch information
Joseli.to committed Nov 7, 2018
2 parents 5b975ea + 2808383 commit 1e56ef2
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 26 deletions.

This file was deleted.

44 changes: 44 additions & 0 deletions scripts/config/webpack.night.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { resolve } = require('path');
const { existsSync } = require('fs-extra');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlStringReplace = require('html-replace-webpack-plugin');
const getBasePath = require('../helpers/getBasePath');

const basePath = getBasePath();

const entry = existsSync(resolve(basePath, './public/index.js'))
? ['./src/index.js', './public/index.js']
: './src/index.js';

module.exports = () => ({
mode: 'development',
resolve: {
mainFields: ['module', 'jsnext:main', 'main'],
},
context: resolve(basePath),
entry,
devServer: {
open: false,
hot: false,
host: '127.0.0.1',
historyApiFallback: true,
publicPath: '/',
contentBase: [
resolve(`${basePath}/public`),
resolve('./packages'),
],
watchContentBase: true,
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
inject: 'body',
template: './public/index.html',
}),
new HtmlStringReplace([{
pattern: /<script.*?injectDependencies.*?\/script>/,
replacement: '',
}]),
],
});
16 changes: 9 additions & 7 deletions scripts/night.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { exec } = require('shelljs');
const { exec, env } = require('shelljs');
const { join } = require('path');
const camelcase = require('camelcase');
const os = require('os');
Expand All @@ -14,24 +14,26 @@ if (scope === '*') {
console.log(`Testing ${scope !== '*' ? scope : 'all packages'}\n`);

const nightwatchBin = join('node_modules/.bin/nightwatch');
const httpServerBin = join('node_modules/.bin/http-server');

const webpackDevServer = join('node_modules/.bin/webpack-dev-server');
const webpackConfig = join('scripts/config/webpack.night.config.js');

const setupSelenium = 'node selenium-setup';
const httpSever = `${httpServerBin} . -s -p 8777 -c-1`;

const testFile = `packages/${scope}/src/component/${camelcase(scope).replace('slingWebComponent', '')}.regression.test.js`;

env.PKG = scope;

if (os.platform() === 'win32') {
const killNode = 'taskkill /im node.exe /F';
exec(`${setupSelenium}`)
exec(`call start /MIN "h" ${httpSever}`, { async: true });

exec(`${setupSelenium}`);
exec(`call start /MIN "webpack" ${webpackDevServer} --config ${webpackConfig} --port 8777`, { async: true });

setTimeout(() => {
exec(`${nightwatchBin} ${testFile} && ${killNode}`);
}, 1000);

} else {
const killNode = 'kill $(ps aux | grep \'node\' | awk \'{print $2}\')';
exec(`${setupSelenium} && ${httpSever} & ${nightwatchBin} ${testFile} && ${killNode}`);
exec(`${setupSelenium} && ${webpackDevServer} --config ${webpackConfig} --port 8777 & ${nightwatchBin} ${testFile} && ${killNode}`);
}

0 comments on commit 1e56ef2

Please sign in to comment.