codeceptjs 4.0.0-beta.23 → 4.0.0-beta.24

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.
@@ -69,13 +69,33 @@ class JSONResponse extends Helper {
69
69
 
70
70
  _beforeSuite() {
71
71
  this.response = null
72
- if (!this.helpers[this.options.requestHelper]) {
73
- throw new Error(`Error setting JSONResponse, helper ${this.options.requestHelper} is not enabled in config, helpers: ${Object.keys(this.helpers)}`)
74
- }
75
- const origOnResponse = this.helpers[this.options.requestHelper].config.onResponse
76
- this.helpers[this.options.requestHelper].config.onResponse = response => {
77
- this.response = response
78
- if (typeof origOnResponse === 'function') origOnResponse(response)
72
+
73
+ try {
74
+ const requestHelper = this.helpers[this.options.requestHelper]
75
+
76
+ if (!requestHelper) {
77
+ const helperNames = Object.keys(this.helpers || {})
78
+ const errorMsg = `Error setting JSONResponse, helper ${this.options.requestHelper} is not enabled in config, helpers: ${helperNames.join(', ') || 'none'}`
79
+ this.debugSection('JSONResponse', errorMsg)
80
+ // Don't throw - just warn and return to avoid hanging
81
+ console.warn(`[JSONResponse] ${errorMsg}`)
82
+ return
83
+ }
84
+
85
+ // Ensure the helper has a config object
86
+ if (!requestHelper.config) {
87
+ requestHelper.config = {}
88
+ }
89
+
90
+ const origOnResponse = requestHelper.config.onResponse
91
+ requestHelper.config.onResponse = response => {
92
+ this.response = response
93
+ if (typeof origOnResponse === 'function') origOnResponse(response)
94
+ }
95
+ } catch (error) {
96
+ // Log the error but don't throw to avoid hanging the recorder
97
+ console.error(`[JSONResponse._beforeSuite] ${error.message}`)
98
+ this.debugSection('JSONResponse Error', error.message)
79
99
  }
80
100
  }
81
101
 
@@ -83,7 +103,6 @@ class JSONResponse extends Helper {
83
103
  this.response = null
84
104
  }
85
105
 
86
-
87
106
  /**
88
107
  * Checks that response code is equal to the provided one
89
108
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "4.0.0-beta.23",
3
+ "version": "4.0.0-beta.24",
4
4
  "type": "module",
5
5
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
6
6
  "keywords": [