Spec file debugger 4 #57
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
name: Test | ||
on: [push, pull_request] | ||
jobs: | ||
CypressMockTests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
container: [1, 2, 3, 4, 5] # Creates 5 parallel executions for Cypress tests. | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/[email protected] | ||
with: | ||
node-version: '18.x' | ||
- name: Install Node.js packages for Cypress | ||
run: npm install | ||
- name: Get test files | ||
id: test-files | ||
run: | | ||
echo "Current working directory:" | ||
pwd | ||
TEST_DIR="frontend/src/__tests__/cypress/cypress/tests/mocked" | ||
echo "Listing contents of the current directory:" | ||
ls -la | ||
echo "Checking for test files in $TEST_DIR" | ||
echo "Listing contents of frontend/src/__tests__/cypress/cypress/tests:" | ||
ls -la frontend/src/__tests__/cypress/cypress/tests/ | ||
if [ -d "$TEST_DIR" ]; then | ||
echo "Listing contents of mocked directory:" | ||
ls -la "$TEST_DIR" | ||
TEST_FILES=$(find "$TEST_DIR" -name "*.cy.ts" | tr '\n' ',') | ||
echo "Found test files: $TEST_FILES" | ||
echo "files=$TEST_FILES" >> $GITHUB_OUTPUT | ||
else | ||
echo "Directory does not exist. No test files found." >> $GITHUB_OUTPUT | ||
echo "files=" >> $GITHUB_OUTPUT # Set empty output if no files found | ||
fi | ||
- name: Run Cypress Mock Tests in Parallel | ||
env: | ||
CONTAINER_INDEX: ${{ matrix.container }} | ||
TEST_FILES: ${{ steps.test-files.outputs.files }} | ||
run: | | ||
echo "Running Cypress tests for container $CONTAINER_INDEX..." | ||
echo "Test Files: $TEST_FILES" | ||
# Generate the list of spec files for this container and trim trailing comma | ||
SPEC_FILES=$(echo "$TEST_FILES" | tr ',' '\n' | awk -v container="$CONTAINER_INDEX" 'NR % 5 == container - 1' | tr '\n' ',' | sed 's/,$//') | ||
# Check if SPEC_FILES is empty | ||
if [ -z "$SPEC_FILES" ]; then | ||
echo "No spec files found for container $CONTAINER_INDEX. Skipping Cypress tests." | ||
exit 0 | ||
else | ||
echo "Spec files for this container- $SPEC_FILES" | ||
cd ./frontend && npm run test:cypress-ci -- --headless --no-sandbox --spec "$SPEC_FILES" | ||
fi | ||
- uses: actions/upload-artifact@v4 | ||
if: ${{ always() }} | ||
with: | ||
name: cypress-results-${{ strategy.job-index }} | ||
path: ./frontend/src/__tests__/cypress/results/ | ||
overwrite: true |