@@ -5,8 +5,10 @@ import { reportStudioError } from '@packages/server/lib/cloud/api/studio/report_
5
5
describe ( 'lib/cloud/api/studio/report_studio_error' , ( ) => {
6
6
let cloudRequestStub : sinon . SinonStub
7
7
let cloudApi : any
8
+ let oldNodeEnv : string | undefined
8
9
9
10
beforeEach ( ( ) => {
11
+ oldNodeEnv = process . env . NODE_ENV
10
12
cloudRequestStub = sinon . stub ( )
11
13
cloudApi = {
12
14
cloudUrl : 'http://localhost:1234' ,
@@ -19,6 +21,14 @@ describe('lib/cloud/api/studio/report_studio_error', () => {
19
21
20
22
afterEach ( ( ) => {
21
23
sinon . restore ( )
24
+ delete process . env . CYPRESS_CRASH_REPORTS
25
+ delete process . env . CYPRESS_LOCAL_STUDIO_PATH
26
+ delete process . env . CYPRESS_INTERNAL_E2E_TESTING_SELF
27
+ if ( oldNodeEnv ) {
28
+ process . env . NODE_ENV = oldNodeEnv
29
+ } else {
30
+ delete process . env . NODE_ENV
31
+ }
22
32
} )
23
33
24
34
describe ( 'reportStudioError' , ( ) => {
@@ -82,6 +92,21 @@ describe('lib/cloud/api/studio/report_studio_error', () => {
82
92
)
83
93
} )
84
94
95
+ it ( 'does not report error when CYPRESS_CRASH_REPORTS is 0' , ( ) => {
96
+ process . env . CYPRESS_CRASH_REPORTS = '0'
97
+ const error = new Error ( 'test error' )
98
+
99
+ reportStudioError ( {
100
+ cloudApi,
101
+ studioHash : 'abc123' ,
102
+ projectSlug : 'test-project' ,
103
+ error,
104
+ studioMethod : 'testMethod' ,
105
+ } )
106
+
107
+ expect ( cloudRequestStub ) . to . not . have . been . called
108
+ } )
109
+
85
110
it ( 'converts non-Error objects to Error' , ( ) => {
86
111
const error = 'string error'
87
112
@@ -152,7 +177,7 @@ describe('lib/cloud/api/studio/report_studio_error', () => {
152
177
153
178
it ( 'includes studioMethodArgs when provided' , ( ) => {
154
179
const error = new Error ( 'test error' )
155
- const args = [ 'arg1' , { key : 'value ' } ]
180
+ const args = [ 'arg1' , { key : '/path/to/file.js ' } ]
156
181
157
182
reportStudioError ( {
158
183
cloudApi,
@@ -173,7 +198,7 @@ describe('lib/cloud/api/studio/report_studio_error', () => {
173
198
message : 'test error' ,
174
199
stack : sinon . match ( ( stack ) => stack . includes ( '<stripped-path>report_studio_error_spec.ts' ) ) ,
175
200
studioMethod : 'testMethod' ,
176
- studioMethodArgs : JSON . stringify ( { args } ) ,
201
+ studioMethodArgs : JSON . stringify ( { args : [ 'arg1' , { key : '<stripped-path>file.js' } ] } ) ,
177
202
} ] ,
178
203
} ,
179
204
{
0 commit comments