Skip to content

Commit 69f1557

Browse files
authored
render hook names if present (#137)
* update cck dependency * render hook name if present * update CHANGELOG.md * add overrides for messages dep
1 parent 00cb71d commit 69f1557

File tree

5 files changed

+64
-152
lines changed

5 files changed

+64
-152
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
9+
### Added
10+
- Render hook names if present ([#137](https://github.com/cucumber/cucumber-react/pull/137))
911
### Changed
1012
- Scenario outline styling - Examples changed to H3 and aligned with steps
1113

package-lock.json

Lines changed: 22 additions & 150 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
},
5353
"devDependencies": {
5454
"@babel/core": "7.17.9",
55-
"@cucumber/compatibility-kit": "^9.1.2",
55+
"@cucumber/compatibility-kit": "^9.2.0",
5656
"@cucumber/fake-cucumber": "^15.0.0",
5757
"@cucumber/gherkin": "^23.0.1",
5858
"@cucumber/gherkin-streams": "^5.0.1",
@@ -104,6 +104,9 @@
104104
"ts-jest": "^27.1.4",
105105
"typescript": "4.6.3"
106106
},
107+
"overrides": {
108+
"@cucumber/messages": "^18.0.0"
109+
},
107110
"bugs": {
108111
"url": "https://github.com/cucumber/cucumber/issues"
109112
},

src/components/gherkin/HookStep.spec.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,39 @@ describe('<HookStep>', () => {
149149

150150
expect(container).toHaveTextContent('Hook failed: MyHooks.doSetup')
151151
})
152+
153+
it('renders the name when present for a failed hook', () => {
154+
const step: messages.TestStep = {
155+
id: '123',
156+
hookId: '456',
157+
}
158+
159+
const { container } = render(<HookStep step={step} />, {
160+
cucumberQuery: new StubCucumberQuery(
161+
[
162+
{
163+
status: messages.TestStepResultStatus.FAILED,
164+
message: 'whoops',
165+
duration: {
166+
seconds: 1,
167+
nanos: 0,
168+
},
169+
},
170+
],
171+
{
172+
id: '456',
173+
name: 'fancy hook!',
174+
sourceReference: {
175+
uri: 'features/support/hooks.js',
176+
location: {
177+
line: 4,
178+
column: 6,
179+
},
180+
},
181+
}
182+
),
183+
})
184+
185+
expect(container).toHaveTextContent('Hook "fancy hook!" failed:')
186+
})
152187
})

src/components/gherkin/HookStep.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const DefaultRenderer: React.FunctionComponent<HookStepProps> = ({ step }) => {
2929
return (
3030
<StepItem status={stepResult.status}>
3131
<Title header="h3" id={step.id}>
32-
Hook failed: {location}
32+
{hook?.name ? `Hook "${hook.name}"` : 'Hook'} failed: {location}
3333
</Title>
3434
{stepResult.message && <ErrorMessage message={stepResult.message} />}
3535
{attachments.map((attachment, i) => (

0 commit comments

Comments
 (0)