File tree Expand file tree Collapse file tree 4 files changed +20
-11
lines changed Expand file tree Collapse file tree 4 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -66,16 +66,11 @@ const registerHooks = () => {
66
66
windowCoverageObjects = [ ]
67
67
68
68
const saveCoverageObject = ( win ) => {
69
- // accessing win.__coverage__ will error when testing cross-origin code
70
- // because we don't control cross-origin code anyway, we can safely return
71
- try {
72
- win . __coverage__
73
- } catch {
74
- return
75
- }
76
-
77
- // if application code has been instrumented, the app iframe "window" has an object
78
- const applicationSourceCoverage = win . __coverage__
69
+ // if the application code has been instrumented, then the app iframe "win.__coverage__" will be available,
70
+ // in addition, accessing win.__coverage__ can throw when testing cross-origin code,
71
+ // because we don't control the cross-origin code, we can safely return
72
+ let applicationSourceCoverage
73
+ try { applicationSourceCoverage = win ?. __coverage__ } catch { }
79
74
if ( ! applicationSourceCoverage ) {
80
75
return
81
76
}
Original file line number Diff line number Diff line change 1
1
{
2
- "plugins" : [" istanbul" ]
2
+ "plugins" : [" istanbul" ],
3
+ "ignore" : [" **/*.cy.js" ]
3
4
}
Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ module.exports = defineConfig({
6
6
setupNodeEvents ( on , config ) {
7
7
return require ( './cypress/plugins/index.js' ) ( on , config )
8
8
} ,
9
+ hosts : {
10
+ 'foobar.com' : '127.0.0.1' ,
11
+ } ,
9
12
baseUrl : 'http://localhost:1234' ,
10
13
env : {
11
14
codeCoverage : {
Original file line number Diff line number Diff line change @@ -25,6 +25,16 @@ context('Page test', () => {
25
25
cy . contains ( 'h2' , 'About' )
26
26
cy . contains ( 'Est. 2019' )
27
27
} )
28
+
29
+ it ( 'loads cross origin page using cy.origin' , ( ) => {
30
+ cy . origin ( 'http://foobar.com:1234' , ( ) => {
31
+ cy . visit ( '/' )
32
+ } )
33
+ } )
34
+
35
+ it ( 'loads cross origin page without cy.origin' , ( ) => {
36
+ cy . visit ( 'http://foobar.com:1234' )
37
+ } )
28
38
} )
29
39
30
40
context ( 'Unit tests' , ( ) => {
You can’t perform that action at this time.
0 commit comments