You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* A helper for running arbitrary MongoDB Driver scripting code in a resource information collecting script.
126
+
* This script uses info from node:process to collect resource information.
127
+
*
128
+
* **The provided function is run in an isolated Node.js process**
129
+
*
130
+
* A user of this function will likely need to familiarize themselves with the surrounding scripting, but briefly:
131
+
* - Every MongoClient you construct should have an asyncResource attached to it like so:
132
+
* ```js
133
+
* mongoClient.asyncResource = new this.async_hooks.AsyncResource('MongoClient');
134
+
* ```
135
+
* - You can perform any number of operations and connects/closes of MongoClients
136
+
* - This function performs assertions that at the end of the provided function, the js event loop has been exhausted
137
+
*
138
+
* @param name - the name of the script, this defines the name of the file, it will be cleaned up if the function returns successfully
139
+
* @param config - `this.configuration` from your mocha config
140
+
* @param func - your javascript function, you can write it inline! this will stringify the function, use the references on the `this` context to get typechecking
141
+
* @param options - settings for the script
142
+
* @throws Error - if the process exits with failure or if the process' resources are not cleaned up by the provided function.
143
+
*/
144
+
exportasyncfunctionrunScriptAndGetProcessInfo(
115
145
name: string,
116
146
config: TestConfiguration,
117
-
func: ResourceTestFunction
147
+
func: ProcessResourceTestFunction
118
148
){
119
149
120
150
constscriptName=`${name}.cjs`;
@@ -137,15 +167,23 @@ export async function runScriptAndReturnResourceInfo(
0 commit comments