dd-trace 6.0.0-pre-51a58bc → 6.0.0-pre-386f4e7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "6.0.0-pre-51a58bc",
3
+ "version": "6.0.0-pre-386f4e7",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -4,6 +4,10 @@ let isKnownTestsEnabled = false
4
4
  let knownTestsForSuite = []
5
5
  let suiteTests = []
6
6
  let earlyFlakeDetectionNumRetries = 0
7
+ // We need to grab the original window as soon as possible,
8
+ // in case the test changes the origin. If the test does change the origin,
9
+ // any call to `cy.window()` will result in a cross origin error.
10
+ let originalWindow
7
11
 
8
12
  // If the test is using multi domain with cy.origin, trying to access
9
13
  // window properties will result in a cross origin error.
@@ -61,6 +65,9 @@ beforeEach(function () {
61
65
  this.skip()
62
66
  }
63
67
  })
68
+ cy.window().then(win => {
69
+ originalWindow = win
70
+ })
64
71
  })
65
72
 
66
73
  before(function () {
@@ -78,39 +85,39 @@ before(function () {
78
85
  })
79
86
 
80
87
  after(() => {
81
- cy.window().then(win => {
82
- if (safeGetRum(win)) {
83
- win.dispatchEvent(new Event('beforeunload'))
88
+ try {
89
+ if (safeGetRum(originalWindow)) {
90
+ originalWindow.dispatchEvent(new Event('beforeunload'))
84
91
  }
85
- })
92
+ } catch (e) {
93
+ // ignore error. It's usually a multi origin issue.
94
+ }
86
95
  })
87
96
 
88
97
 
89
98
  afterEach(function () {
90
- cy.window().then(win => {
91
- const currentTest = Cypress.mocha.getRunner().suite.ctx.currentTest
92
- const testInfo = {
93
- testName: currentTest.fullTitle(),
94
- testSuite: Cypress.mocha.getRootSuite().file,
95
- testSuiteAbsolutePath: Cypress.spec && Cypress.spec.absolute,
96
- state: currentTest.state,
97
- error: currentTest.err,
98
- isNew: currentTest._ddIsNew,
99
- isEfdRetry: currentTest._ddIsEfdRetry
100
- }
101
- try {
102
- testInfo.testSourceLine = Cypress.mocha.getRunner().currentRunnable.invocationDetails.line
103
- } catch (e) {}
99
+ const currentTest = Cypress.mocha.getRunner().suite.ctx.currentTest
100
+ const testInfo = {
101
+ testName: currentTest.fullTitle(),
102
+ testSuite: Cypress.mocha.getRootSuite().file,
103
+ testSuiteAbsolutePath: Cypress.spec && Cypress.spec.absolute,
104
+ state: currentTest.state,
105
+ error: currentTest.err,
106
+ isNew: currentTest._ddIsNew,
107
+ isEfdRetry: currentTest._ddIsEfdRetry
108
+ }
109
+ try {
110
+ testInfo.testSourceLine = Cypress.mocha.getRunner().currentRunnable.invocationDetails.line
111
+ } catch (e) {}
104
112
 
105
- if (safeGetRum(win)) {
106
- testInfo.isRUMActive = true
107
- }
108
- let coverage
109
- try {
110
- coverage = win.__coverage__
111
- } catch (e) {
112
- // ignore error and continue
113
- }
114
- cy.task('dd:afterEach', { test: testInfo, coverage })
115
- })
113
+ if (safeGetRum(originalWindow)) {
114
+ testInfo.isRUMActive = true
115
+ }
116
+ let coverage
117
+ try {
118
+ coverage = originalWindow.__coverage__
119
+ } catch (e) {
120
+ // ignore error and continue
121
+ }
122
+ cy.task('dd:afterEach', { test: testInfo, coverage })
116
123
  })