Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: capture the beforeTest timestamp in the app before sending it to protocol for a more accurate timestamp #29061

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/app/src/runner/events/capture-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,17 @@ export const addCaptureProtocolListeners = (Cypress: Cypress.Cypress) => {
Cypress.primaryOriginCommunicator.on('viewport:changed', viewportChangedHandler)

Cypress.on('test:before:run:async', async (attributes) => {
const timestamp = performance.now() + performance.timeOrigin

attachCypressProtocolInfo({
type: 'test:before:run:async',
timestamp: performance.now() + performance.timeOrigin,
timestamp,
})

await Cypress.backend('protocol:test:before:run:async', attributes)
await Cypress.backend('protocol:test:before:run:async', {
...attributes,
timestamp,
})
})

Cypress.on('url:changed', (url) => {
Expand Down
51 changes: 34 additions & 17 deletions system-tests/__snapshots__/protocol_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ exports['e2e events'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 10000
"_slow": 10000,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -135,7 +136,8 @@ exports['e2e events'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 10000
"_slow": 10000,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -202,7 +204,8 @@ exports['e2e events'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 10000
"_slow": 10000,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -269,7 +272,8 @@ exports['e2e events'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 10000
"_slow": 10000,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -336,7 +340,8 @@ exports['e2e events'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 10000
"_slow": 10000,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -403,7 +408,8 @@ exports['e2e events'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 10000
"_slow": 10000,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -470,7 +476,8 @@ exports['e2e events'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 10000
"_slow": 10000,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -537,7 +544,8 @@ exports['e2e events'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 10000
"_slow": 10000,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -604,7 +612,8 @@ exports['e2e events'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 10000
"_slow": 10000,
"timestamp": "Any.Number"
}
],
"preAfterTest": [
Expand Down Expand Up @@ -5156,7 +5165,8 @@ exports['component events - experimentalSingleTabRunMode: true'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 250
"_slow": 250,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -5185,7 +5195,8 @@ exports['component events - experimentalSingleTabRunMode: true'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 250
"_slow": 250,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -5214,7 +5225,8 @@ exports['component events - experimentalSingleTabRunMode: true'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 250
"_slow": 250,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -5243,7 +5255,8 @@ exports['component events - experimentalSingleTabRunMode: true'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 250
"_slow": 250,
"timestamp": "Any.Number"
}
],
"preAfterTest": [
Expand Down Expand Up @@ -6883,7 +6896,8 @@ exports['component events - experimentalSingleTabRunMode: false'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 250
"_slow": 250,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -6912,7 +6926,8 @@ exports['component events - experimentalSingleTabRunMode: false'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 250
"_slow": 250,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -6941,7 +6956,8 @@ exports['component events - experimentalSingleTabRunMode: false'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 250
"_slow": 250,
"timestamp": "Any.Number"
},
{
"_testConfig": {
Expand Down Expand Up @@ -6970,7 +6986,8 @@ exports['component events - experimentalSingleTabRunMode: false'] = `
},
"currentRetry": 0,
"retries": 0,
"_slow": 250
"_slow": 250,
"timestamp": "Any.Number"
}
],
"preAfterTest": [
Expand Down
Loading