Skip to content

Commit 9555d42

Browse files
Pwd9000-MLMarcel-AVACopilot
authored
fix: accept both calculator.test.js and calculator.tests.js in Step 3 workflow (#33)
The Step 3 CI workflow hardcoded the test file path as src/tests/calculator.tests.js, but users following standard Jest conventions naturally create calculator.test.js (singular). This caused the keyphrase checker to fail with 'File does not exist' even though all tests passed. Changes: - Add a detect step that checks for either calculator.test.js or calculator.tests.js and outputs the path for downstream steps - Update step docs (2-step.md, 3-step.md) to use the standard Jest naming convention (calculator.test.js) Fixes #32 Co-authored-by: Marcel Lupo <marcel.lupo@avanade.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a613f2d commit 9555d42

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

.github/steps/2-step.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Use the `!` command in Copilot CLI to execute shell commands directly from your
128128
> Create comprehensive unit tests for all the calculator functions:
129129
> - Expand tests based on the following example:
130130
> - @images/calc-basic-operations.png
131-
> - Add these tests to a src/tests/calculator.tests.js file
131+
> - Add these tests to a src/tests/calculator.test.js file
132132
> - Use a popular Node.js testing framework if one isn't installed
133133
> - addition, subtraction, multiplication, and division
134134
> - test edge cases like division by zero

.github/steps/3-step.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ As you add features, Copilot CLI can help you:
112112
> Add tests for the new calculator operations:
113113
> - Expand tests based on the following example:
114114
> - @images/calc-extended-operations.png
115-
> - Add new tests for the new operations to the existing src/tests/calculator.tests.js file
115+
> - Add new tests for the new operations to the existing src/tests/calculator.test.js file
116116
> - Use a popular Node.js testing framework if one isn't installed
117117
> - Make sure to include edge case tests like square root of negative numbers
118118
> - Make sure all tests run and pass

.github/workflows/3-step.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,40 @@ jobs:
5757
file: exercise-toolkit/markdown-templates/step-feedback/checking-work.md
5858
edit-mode: replace
5959

60-
- name: Check if calculator.tests.js has a modulo test
60+
- name: Detect calculator test file
61+
id: detect-test-file
62+
run: |
63+
if [ -f "src/tests/calculator.test.js" ]; then
64+
echo "path=src/tests/calculator.test.js" >> "$GITHUB_OUTPUT"
65+
elif [ -f "src/tests/calculator.tests.js" ]; then
66+
echo "path=src/tests/calculator.tests.js" >> "$GITHUB_OUTPUT"
67+
else
68+
echo "::error::Expected src/tests/calculator.test.js or src/tests/calculator.tests.js but neither was found"
69+
exit 1
70+
fi
71+
72+
- name: Check if calculator test file has a modulo test
6173
id: check-modulo-test
6274
continue-on-error: true
6375
uses: skills/action-keyphrase-checker@v1
6476
with:
65-
text-file: src/tests/calculator.tests.js
77+
text-file: ${{ steps.detect-test-file.outputs.path }}
6678
keyphrase: modulo
6779

68-
- name: Check if calculator.tests.js has a power test
80+
- name: Check if calculator test file has a power test
6981
id: check-power-test
7082
continue-on-error: true
7183
uses: skills/action-keyphrase-checker@v1
7284
with:
73-
text-file: src/tests/calculator.tests.js
85+
text-file: ${{ steps.detect-test-file.outputs.path }}
7486
keyphrase: power
7587

76-
- name: Check if calculator.tests.js has a 'square root' test
88+
- name: Check if calculator test file has a 'square root' test
7789
id: check-sqrt-test
7890
continue-on-error: true
7991
uses: skills/action-keyphrase-checker@v1
8092
with:
81-
text-file: src/tests/calculator.tests.js
93+
text-file: ${{ steps.detect-test-file.outputs.path }}
8294
keyphrase: 'square'
8395

8496
- name: Update comment - step results

0 commit comments

Comments
 (0)