Skip to content

Commit ba7a47e

Browse files
committed
add timeouts to fixture
1 parent 752423e commit ba7a47e

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

test/browser/features/component-lifecycle-spans.feature

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
Feature: Component lifecycle spans
33
Scenario: Component lifecycle spans are automatically instrumented
44
Given I navigate to the test URL "/docs/react"
5-
And I click the element "update-component"
6-
Then I click the element "unmount-component"
7-
Then I click the element "end-page-load"
85
When I wait to receive 1 trace
96
Then a span name equals "[ViewLoad/Component]Component"
107
And a span name equals "[ViewLoadPhase/Mount]Component"
118
And a span name equals "[ViewLoadPhase/Update]Component"
129
And a span name equals "[ViewLoadPhase/Unmount]Component"
1310
# [ViewLoadPhase/Update]Component attributes
14-
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" string array attribute "bugsnag.component.update.props" equals the array:
11+
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.2" string array attribute "bugsnag.component.update.props" equals the array:
1512
| count |
1613

1714
@skip

test/browser/features/fixtures/packages/react/src/index.jsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,25 @@ const KeepAlive = () => {
4343
}
4444

4545
const Root = () => {
46-
const [show, setShow] = React.useState(true)
46+
const [show, setShow] = React.useState(false)
4747
const [count, setCount] = React.useState(0)
4848

49+
useEffect(() => {
50+
(async () => {
51+
await new Promise(resolve => setTimeout(resolve, 100))
52+
setShow(true)
53+
await new Promise(resolve => setTimeout(resolve, 100))
54+
setCount(n => n + 1)
55+
await new Promise(resolve => setTimeout(resolve, 100))
56+
setShow(false)
57+
await new Promise(resolve => setTimeout(resolve, 100))
58+
document.getElementById("end-page-load").click()
59+
})()
60+
}, [])
61+
4962
return (
5063
<div>
5164
<KeepAlive />
52-
<button id="update-component" onClick={() => setCount(prevCount => prevCount + 1)}>
53-
Increment
54-
</button>
55-
<button id="unmount-component" onClick={() => { setShow(false) }}>
56-
Unmount Component
57-
</button>
5865
{show && <WrappedComponent count={count} />}
5966
</div>
6067
)

0 commit comments

Comments
 (0)