- Building Enterprise JavaScript Applications
- Daniel Li
- 145字
- 2021-07-23 16:31:31
Running our tests
Finally, we are able to run our tests! Add the cucumber-js command just prior to the kill command:
npx cucumber-js spec/cucumber/features --require-module @babel/register --require spec/cucumber/steps
Your final scripts/e2e.test.sh script should look like this (comments removed):
#!/usr/bin/env bash
if ss -lnt | grep -q :$SERVER_PORT; then
echo "Another process is already listening to port $SERVER_PORT"
exit 1;
fi
RETRY_INTERVAL=${RETRY_INTERVAL:-0.2}
if ! systemctl is-active --quiet elasticsearch.service; then
sudo systemctl start elasticsearch.service
until curl --silent $ELASTICSEARCH_HOSTNAME:$ELASTICSEARCH_PORT -w "" -o /dev/null; do
sleep $RETRY_INTERVAL
done
fi
yarn run serve &
until ss -lnt | grep -q :$SERVER_PORT; do
sleep $RETRY_INTERVAL
done
npx cucumber-js spec/cucumber/features --require-module @babel/register --require spec/cucumber/steps
kill -15 0
Just to double-check, run the E2E tests to make sure they still pass. Of course, commit these changes to Git:
$ git add -A && git commit -m "Make standalone E2E test script"