codeceptjs 4.0.0-beta.22 → 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.
- package/lib/helper/JSONResponse.js +27 -8
- package/package.json +1 -1
|
@@ -69,13 +69,33 @@ class JSONResponse extends Helper {
|
|
|
69
69
|
|
|
70
70
|
_beforeSuite() {
|
|
71
71
|
this.response = null
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
*
|