chore: Enhance frontend CI workflow for improved test coverage reporting
Some checks failed
LabFusion CI/CD Pipeline / api-gateway (push) Failing after 41s
Docker Build and Push / build-and-push (push) Failing after 41s
LabFusion CI/CD Pipeline / service-adapters (push) Successful in 57s
Integration Tests / integration-tests (push) Failing after 40s
Integration Tests / performance-tests (push) Has been skipped
LabFusion CI/CD Pipeline / api-docs (push) Successful in 1m44s
Frontend (React) / test (20) (push) Failing after 1m29s
Frontend (React) / build (push) Has been skipped
Frontend (React) / lighthouse (push) Has been skipped
LabFusion CI/CD Pipeline / frontend (push) Successful in 4m1s
LabFusion CI/CD Pipeline / integration-tests (push) Has been skipped
Some checks failed
LabFusion CI/CD Pipeline / api-gateway (push) Failing after 41s
Docker Build and Push / build-and-push (push) Failing after 41s
LabFusion CI/CD Pipeline / service-adapters (push) Successful in 57s
Integration Tests / integration-tests (push) Failing after 40s
Integration Tests / performance-tests (push) Has been skipped
LabFusion CI/CD Pipeline / api-docs (push) Successful in 1m44s
Frontend (React) / test (20) (push) Failing after 1m29s
Frontend (React) / build (push) Has been skipped
Frontend (React) / lighthouse (push) Has been skipped
LabFusion CI/CD Pipeline / frontend (push) Successful in 4m1s
LabFusion CI/CD Pipeline / integration-tests (push) Has been skipped
### Summary of Changes - Updated the test command in the CI workflow to use `npx vitest` for running tests with coverage. - Added a verification step to check for the presence of coverage files (`lcov.info` and `clover.xml`). - Configured Vitest to output JUnit test results and detailed coverage reports in the specified directory. ### Expected Results - Improved visibility and reliability of test coverage metrics, facilitating better quality assurance processes.
This commit is contained in:
@@ -70,8 +70,23 @@ jobs:
|
|||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
npm test -- --run --coverage --reporter=verbose
|
npx vitest run --coverage --reporter=verbose
|
||||||
npm run test:coverage
|
|
||||||
|
- name: Verify coverage files
|
||||||
|
run: |
|
||||||
|
echo "Checking coverage files..."
|
||||||
|
ls -la coverage/
|
||||||
|
echo "Required coverage files:"
|
||||||
|
if [ -f "coverage/lcov.info" ]; then
|
||||||
|
echo "✓ lcov.info found"
|
||||||
|
else
|
||||||
|
echo "✗ lcov.info missing"
|
||||||
|
fi
|
||||||
|
if [ -f "coverage/clover.xml" ]; then
|
||||||
|
echo "✓ clover.xml found"
|
||||||
|
else
|
||||||
|
echo "✗ clover.xml missing"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Send results to SonarQube
|
- name: Send results to SonarQube
|
||||||
run: |
|
run: |
|
||||||
@@ -84,7 +99,11 @@ jobs:
|
|||||||
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
|
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
|
||||||
-Dsonar.login=${{ secrets.SONAR_TOKEN }} \
|
-Dsonar.login=${{ secrets.SONAR_TOKEN }} \
|
||||||
-Dsonar.projectKey=labfusion-frontend \
|
-Dsonar.projectKey=labfusion-frontend \
|
||||||
-Dsonar.projectName=LabFusion Frontend
|
-Dsonar.projectName=LabFusion Frontend \
|
||||||
|
-Dsonar.sources=src \
|
||||||
|
-Dsonar.tests=src \
|
||||||
|
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info \
|
||||||
|
-Dsonar.coverageReportPaths=coverage/clover.xml
|
||||||
|
|
||||||
- name: Test results summary
|
- name: Test results summary
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
@@ -7,5 +7,21 @@ export default defineConfig({
|
|||||||
environment: 'jsdom',
|
environment: 'jsdom',
|
||||||
setupFiles: ['./src/setupTests.js'],
|
setupFiles: ['./src/setupTests.js'],
|
||||||
globals: true,
|
globals: true,
|
||||||
|
reporter: ['verbose', 'junit'],
|
||||||
|
outputFile: {
|
||||||
|
junit: './coverage/test-results.xml'
|
||||||
|
},
|
||||||
|
coverage: {
|
||||||
|
provider: 'v8',
|
||||||
|
reporter: ['text', 'html', 'lcov', 'clover'],
|
||||||
|
reportsDirectory: './coverage',
|
||||||
|
include: ['src/**/*.{js,jsx}'],
|
||||||
|
exclude: [
|
||||||
|
'src/**/*.test.{js,jsx}',
|
||||||
|
'src/**/*.spec.{js,jsx}',
|
||||||
|
'src/setupTests.js',
|
||||||
|
'src/index.js'
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user