Skip to content

Commit ee1530f

Browse files
committed
docs: Add documentation for step logging fix
1 parent 5e2d76f commit ee1530f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

STEP_LOGGING_FIX.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Step Logging Fix Documentation
2+
3+
## Problem Statement
4+
Steps were not printed in logs when running either `--verbose` or `--debug` when the I actor method is called not directly in Scenario test file (e.g., in custom steps or page objects) and the custom step doesn't call any child I steps.
5+
6+
## Root Cause
7+
The `MetaStep.run()` method in `lib/step/meta.js` never emitted `event.step.started` and `event.step.finished` events for itself. It only registered a listener to attach itself to child steps. If no child steps were called, the MetaStep was never printed in verbose/debug output.
8+
9+
## Solution
10+
Modified `lib/step/meta.js` to track whether child steps are registered and conditionally emit events only if no children are registered. This prevents duplicate printing while ensuring standalone MetaSteps are visible in output.
11+
12+
## Files Changed
13+
1. `lib/step/meta.js` - Core logic fix
14+
2. `test/unit/step/meta_step_logging_test.js` - Comprehensive unit tests
15+
16+
## Testing
17+
- ✅ 6 new unit tests (all passing)
18+
- ✅ Manual testing with custom steps (verified fix works)
19+
- ✅ Existing tests (no regression)
20+
- ✅ Security scan (CodeQL: 0 alerts)
21+
- ✅ Linting (ESLint: 0 errors)
22+
23+
## Example Output
24+
25+
### Before Fix
26+
```
27+
test with custom step WITHOUT I calls
28+
Scenario()
29+
This is just a console.log
30+
✔ OK in 5ms
31+
```
32+
❌ Step name "I customStepWithoutI" is NOT printed
33+
34+
### After Fix
35+
```
36+
test with custom step WITHOUT I calls
37+
Scenario()
38+
This is just a console.log
39+
I custom step without i
40+
✔ OK in 6ms
41+
```
42+
✅ Step name is now visible!
43+
44+
## Known Limitation
45+
For synchronous MetaSteps without child steps, the step name appears after the function executes (because events are emitted in the finally block). This is an acceptable trade-off to avoid the complexity of predicting whether child steps will be registered.

0 commit comments

Comments
 (0)