update jest config #29
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 workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
name: Run test suits | |
on: | |
push: | |
branches: | |
- dev | |
pull_request: | |
branches: | |
- qa | |
env: | |
BRANCH_NAME: dev | |
jobs: | |
run-integration-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16.x] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Start all microservices in docker container along with mongodb, postgres, redis and kafka | |
run: | | |
echo "Running all the docker containers..." | |
docker compose up -d | |
continue-on-error: ${{ env.ACT && true || false }} | |
- name: Run test cases | |
run: | | |
docker compose run node-app npm test | |
- name: create test report directory | |
run: | | |
pwd | |
ls | |
mkdir ./testResults | |
- name: Clean up Docker containers | |
if: success() || failure() | |
run: | | |
# export BRANCH_NAME=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3` | |
# export JEST_HTML_REPORTER_OUTPUT_PATH=/home/username/jest-test-output/test-reports/"$BRANCH_NAME".html | |
# export JEST_HTML_REPORTER_PAGE_TITLE="$BRANCH_NAME"\ Test\ Report | |
CONTAINER_ID=$(docker-compose ps -q node-app) | |
echo "Container ID: $CONTAINER_ID" | |
pwd | |
ls -R -I node_modules | |
# docker exec $CONTAINER_ID ls -aR // this command will work only on running container | |
docker cp "$CONTAINER_ID:/usr/app" ./testReport | |
ls -R -I node_modules | |
docker compose down --rmi all -v | |
- name: Archive HTML Report | |
if: success() || failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results | |
path: ./testReport/test-report.html | |
# https://afsalbacker.medium.com/a-simple-api-test-automation-setup-using-newman-github-actions-and-slack-f70cfa15efe3 | |
- name: Publish jest test report to slack | |
if: success() || failure() | |
env: | |
SLACK_TOKEN: '${{ env.ACT && env.SLACK_TOKEN || secrets.SLACK_TOKEN }}' | |
SLACK_CHANNEL_ID: '${{ env.ACT && env.SLACK_CHANNEL_ID || secrets.SLACK_CHANNEL_ID }}' | |
uses: MeilCli/slack-upload-file@v3 | |
with: | |
slack_token: ${{ env.SLACK_TOKEN }} | |
channel_id: ${{ env.SLACK_CHANNEL_ID }} | |
file_path: ./testResults/test-report.html | |
file_type: 'html' | |
- uses: geekyeggo/delete-artifact@v2 | |
with: | |
name: test-results |