This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run browser tests in firefox & chrome
- Loading branch information
Zbigniew Zagorski
committed
Jan 9, 2019
1 parent
c5daf85
commit 2c0c9eb
Showing
7 changed files
with
760 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# Run a command with HTTP server serving files from current dir. | ||
# | ||
# Usage | ||
# | ||
# with-http-server.sh [options] COMMAND | ||
# | ||
# ./scripts/with-http-server.sh --port 3333 curl -I http://localhost:3333/index.html | ||
# #just check it works | ||
# | ||
# ./scripts/with-http-server.sh --port 8080 --dir dist/verity-examples \ | ||
# ./node_modules/.bin/nightwatch -c test/e2e/nightwatch-local.conf.js | ||
# | ||
# # run mocha chrome on local files served via HTTP | ||
# | ||
# ./scripts/with-http-server.sh npx mocha-chrome http://localhost:8081/test/index.html | ||
# # run mocha chrome on local files served via HTTP | ||
# | ||
# Options: | ||
# | ||
# --server COMMAND, -s COMMAND | ||
# execute COMMAND as server, default "npx http-server" | ||
# | ||
# --port PORT, -p PORT | ||
# change port number, default 8080 | ||
# | ||
# -C DIR | ||
# --dir DIR | ||
# serve files from DIR, default . | ||
# | ||
|
||
dir=. | ||
port=8080 | ||
while [ -n "$1" ]; do | ||
case "$1" in | ||
--port | -p ) | ||
port=${2} | ||
shift ; shift | ||
;; | ||
--server | -s) | ||
server=${2} | ||
shift; shift | ||
;; | ||
--dir | -C ) | ||
dir=${2} | ||
shift ; shift | ||
;; | ||
*) break ;; | ||
esac | ||
done | ||
|
||
echo "$0: starting http server for $(pwd) on port $port" >&2 | ||
|
||
( | ||
cd $dir | ||
if [ -z "$server" ] ; then | ||
server="npx http-server --silent -a 127.0.0.1 -p $port" | ||
fi | ||
exec $server | ||
) & | ||
|
||
pid=$! | ||
attemptNumber=0 | ||
while ! wget -q -O /dev/null http://127.0.0.1:$port/ 2>/dev/null ; do | ||
# check if process is still alive | ||
if ! kill -0 $pid ; then | ||
echo "$0: http-server exited too early or failed" >&2 | ||
exit 1 | ||
fi | ||
# check if we have some attempts left | ||
if [ "$attemptNumber" -gt 10 ] ; then | ||
echo "$0: timeout waiting for http server, exiting" >&2 | ||
kill $pid || true | ||
wait $pid | ||
exit 1 | ||
fi | ||
attemptNumber=`expr $attemptNumber + 1` | ||
sleep 1 | ||
done | ||
|
||
echo "$0: $@" >&2 | ||
"$@" | ||
exitCode=$? | ||
|
||
kill $pid || true | ||
wait $pid | ||
exit $exitCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es2017", | ||
"target": "es5", | ||
"lib": [ | ||
"es2017", | ||
"dom" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.