Skip to content

Commit 8fd0ce1

Browse files
Merge pull request #13 from monikakonieczna/Task-8-Fix-Report
Task 8: Fix Test Results Report in Github Workflow
2 parents 0c21e8c + 29513c6 commit 8fd0ce1

File tree

4 files changed

+34
-25
lines changed

4 files changed

+34
-25
lines changed

.github/workflows/run-tests-by-group.yml

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,45 @@ jobs:
2020
runs-on: ubuntu-latest
2121

2222
steps:
23-
- name: Checkout code
24-
uses: actions/checkout@v2
23+
- name: Checkout Repository
24+
uses: actions/checkout@v4
2525

26-
- name: Set up Node.js
27-
uses: actions/setup-node@v2
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
2828
with:
29-
node-version: '14' # Adjust based on your project's needs
29+
node-version: '20.x'
3030

3131
- name: Install dependencies
32-
run: npm install # Change if you're using another package manager
32+
run: npm install
3333

3434
- name: Run tests with group
3535
run: |
36-
if [ "${{ github.event.inputs.testGroup }}" == "all" ]; then
37-
npm run test:all
38-
elif [ "${{ github.event.inputs.testGroup }}" == "sanity" ]; then
39-
npm run test:sanity
40-
elif [ "${{ github.event.inputs.testGroup }}" == "single_character" ]; then
41-
npm run test:single_character
42-
elif [ "${{ github.event.inputs.testGroup }}" == "all_characters" ]; then
43-
npm run test:all_characters
44-
elif [ "${{ github.event.inputs.testGroup }}" == "multiple_characters" ]; then
45-
npm run test:multiple_characters
46-
elif [ "${{ github.event.inputs.testGroup }}" == "filter_characters" ]; then
47-
npm run test:filter_characters
48-
fi
36+
case "${{ github.event.inputs.testGroup }}" in
37+
all)
38+
npm run test:all
39+
;;
40+
sanity)
41+
npm run test:sanity
42+
;;
43+
single_character)
44+
npm run test:single_character
45+
;;
46+
all_characters)
47+
npm run test:all_characters
48+
;;
49+
multiple_characters)
50+
npm run test:multiple_characters
51+
;;
52+
filter_characters)
53+
npm run test:filter_characters
54+
;;
55+
esac
4956
env:
5057
CI: true
5158

5259
- name: Upload test results
53-
uses: actions/upload-artifact@v2
60+
uses: actions/upload-artifact@v4
61+
if: always()
5462
with:
5563
name: test-results
56-
path: junit.xml
64+
path: test-report.html

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ lerna-debug.log*
99

1010
# Diagnostic reports (https://nodejs.org/api/report.html)
1111
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12-
junit.xml
12+
test-report.html
1313

1414
# Runtime data
1515
pids

jest.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const config: Config.InitialOptions = {
88
reporters: [
99
"default",
1010
[
11-
"jest-junit",
12-
{ outputDirectory: "./test-results", outputName: "test-results.xml" },
11+
"jest-html-reporter",
12+
{ outputDirectory: "./test-results", outputName: "test-results.html" },
1313
],
1414
],
1515
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
"test:all_characters": "jest --group=all_characters",
1414
"test:multiple_characters": "jest --group=multiple_characters",
1515
"test:filter_characters": "jest --group=filter_characters",
16-
"test:sanity": "jest --ci --reporters=default --reporters=jest-junit --group=sanity_tests"
16+
"test:sanity": "jest --ci --reporters=default --reporters=jest-html-reporter --group=sanity_tests"
1717
},
1818
"devDependencies": {
1919
"@types/jest": "^29.5.12",
2020
"@types/supertest": "^6.0.2",
2121
"jest": "^29.7.0",
2222
"jest-html-reporter": "^3.10.2",
23+
"jest-junit": "^16.0.0",
2324
"jest-runner-groups": "^2.2.0",
2425
"supertest": "^7.0.0",
2526
"ts-jest": "^29.1.4",

0 commit comments

Comments
 (0)