September 2018
Intermediate to advanced
764 pages
20h 6m
English
Although we haven't written any tests yet, we can simply copy the test script we wrote for our API and place it in scripts/e2e.test.sh:
#!/bin/bash# Set environment variables from .env and set NODE_ENV to testsource <(dotenv-export | sed 's/\\n/\n/g')export NODE_ENV=test# Run our web server as a background processyarn run serve > /dev/null 2>&1 &# Polling to see if the server is up and running yetTRIES=0RETRY_LIMIT=50RETRY_INTERVAL=0.2SERVER_UP=falsewhile [ $TRIES -lt $RETRY_LIMIT ]; do if netstat -tulpn 2>/dev/null | grep -q ":$SERVER_PORT_TEST.*LISTEN"; then SERVER_UP=true break else sleep $RETRY_INTERVAL let TRIES=TRIES+1 fidone# Only run this if API server is operationalif $SERVER_UP; then # Run the test in the background ...
Read now
Unlock full access