Skip to content

Commit

Permalink
cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-fernandez committed Aug 30, 2024
1 parent 16a8bb3 commit f51bb22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions integration-tests/cypress/cypress.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ moduleTypes.forEach(({
assert.equal(testSessionEventContent.resource.startsWith('test_session.'), true)
assert.equal(testSessionEventContent.meta[TEST_STATUS], 'fail')

assert.equal(testModuleEventContent.meta[TEST_SESSION_NAME], 'my-test-session')
assert.exists(testModuleEventContent.test_session_id)
assert.exists(testModuleEventContent.test_module_id)
assert.exists(testModuleEventContent.meta[TEST_COMMAND])
Expand Down Expand Up @@ -273,6 +274,7 @@ moduleTypes.forEach(({
test_session_id: testSessionId
}
}) => {
assert.equal(meta[TEST_SESSION_NAME], 'my-test-session')
assert.exists(meta[TEST_COMMAND])
assert.exists(meta[TEST_MODULE])
assert.exists(testSuiteId)
Expand Down Expand Up @@ -300,6 +302,7 @@ moduleTypes.forEach(({
test_session_id: testSessionId
}
}) => {
assert.equal(meta[TEST_SESSION_NAME], 'my-test-session')
assert.exists(meta[TEST_COMMAND])
assert.exists(meta[TEST_MODULE])
assert.exists(testSuiteId)
Expand Down
10 changes: 7 additions & 3 deletions packages/datadog-plugin-cypress/src/cypress-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,12 @@ class CypressPlugin {
const testSuiteSpanMetadata =
getTestSuiteCommonTags(this.command, this.frameworkVersion, suite, TEST_FRAMEWORK_NAME)
this.ciVisEvent(TELEMETRY_EVENT_CREATED, 'suite')

return this.tracer.startSpan(`${TEST_FRAMEWORK_NAME}.test_suite`, {
childOf: this.testModuleSpan,
tags: {
[COMPONENT]: TEST_FRAMEWORK_NAME,
[TEST_SESSION_NAME]: this.testSessionName,
...this.testEnvironmentMetadata,
...testSuiteSpanMetadata
}
Expand All @@ -265,7 +267,8 @@ class CypressPlugin {
const testSuiteTags = {
[TEST_COMMAND]: this.command,
[TEST_COMMAND]: this.command,
[TEST_MODULE]: TEST_FRAMEWORK_NAME
[TEST_MODULE]: TEST_FRAMEWORK_NAME,
[TEST_SESSION_NAME]: this.testSessionName
}
if (this.testSuiteSpan) {
testSuiteTags[TEST_SUITE_ID] = this.testSuiteSpan.context().toSpanId()
Expand Down Expand Up @@ -389,13 +392,13 @@ class CypressPlugin {
testSessionSpanMetadata[TEST_EARLY_FLAKE_ENABLED] = 'true'
}

const testSessionName = getTestSessionName(this.tracer._tracer._config, this.command, this.testEnvironmentMetadata)
this.testSessionName = getTestSessionName(this.tracer._tracer._config, this.command, this.testEnvironmentMetadata)

this.testSessionSpan = this.tracer.startSpan(`${TEST_FRAMEWORK_NAME}.test_session`, {
childOf,
tags: {
[COMPONENT]: TEST_FRAMEWORK_NAME,
[TEST_SESSION_NAME]: testSessionName,
[TEST_SESSION_NAME]: this.testSessionName,
...this.testEnvironmentMetadata,
...testSessionSpanMetadata
}
Expand All @@ -406,6 +409,7 @@ class CypressPlugin {
childOf: this.testSessionSpan,
tags: {
[COMPONENT]: TEST_FRAMEWORK_NAME,
[TEST_SESSION_NAME]: this.testSessionName,
...this.testEnvironmentMetadata,
...testModuleSpanMetadata
}
Expand Down

0 comments on commit f51bb22

Please sign in to comment.