@usebruno/js 0.42.2 → 0.44.0

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.
@@ -10,7 +10,7 @@ const addCryptoUtilsShimToContext = async (vm) => {
10
10
  let randomBytesHandle = vm.newFunction('randomBytes', function (sizeHandle) {
11
11
  try {
12
12
  let size = vm.dump(sizeHandle);
13
-
13
+
14
14
  if (typeof size !== 'number') {
15
15
  throw new TypeError('The "size" argument must be of type number');
16
16
  }
@@ -30,15 +30,14 @@ const addCryptoUtilsShimToContext = async (vm) => {
30
30
  }
31
31
 
32
32
  const buffer = crypto.randomBytes(size);
33
-
33
+
34
34
  const byteArray = Array.from(buffer);
35
-
35
+
36
36
  return marshallToVm(byteArray, vm);
37
-
38
37
  } catch (error) {
39
38
  const vmError = vm.newError(error.message);
40
39
  vm.setProp(vmError, 'name', vm.newString(error.name));
41
-
40
+
42
41
  throw vmError;
43
42
  }
44
43
  });
@@ -48,7 +47,7 @@ const addCryptoUtilsShimToContext = async (vm) => {
48
47
  // Receive the serialized array data directly
49
48
  const serializedArray = vm.dump(arrayHandle);
50
49
  const typedArray = deserializeTypedArray(serializedArray);
51
-
50
+
52
51
  if (typedArray.length === 0) {
53
52
  return marshallToVm([], vm);
54
53
  }
@@ -62,11 +61,10 @@ const addCryptoUtilsShimToContext = async (vm) => {
62
61
  const byteArray = Array.from(typedArray);
63
62
 
64
63
  return marshallToVm(byteArray, vm);
65
-
66
64
  } catch (error) {
67
65
  const vmError = vm.newError(error.message);
68
66
  vm.setProp(vmError, 'name', vm.newString(error.name));
69
-
67
+
70
68
  throw vmError;
71
69
  }
72
70
  });
@@ -101,4 +99,4 @@ const addCryptoUtilsShimToContext = async (vm) => {
101
99
  `);
102
100
  };
103
101
 
104
- module.exports = addCryptoUtilsShimToContext;
102
+ module.exports = addCryptoUtilsShimToContext;
@@ -27,7 +27,7 @@ describe('crypto-utils shims tests', () => {
27
27
  const handle = vm.unwrapResult(result);
28
28
  const type = vm.dump(handle);
29
29
  handle.dispose();
30
-
30
+
31
31
  expect(type).toBe('function');
32
32
  });
33
33
 
@@ -36,7 +36,7 @@ describe('crypto-utils shims tests', () => {
36
36
  const handle = vm.unwrapResult(result);
37
37
  const type = vm.dump(handle);
38
38
  handle.dispose();
39
-
39
+
40
40
  expect(type).toBe('function');
41
41
  });
42
42
 
@@ -45,7 +45,7 @@ describe('crypto-utils shims tests', () => {
45
45
  const handle = vm.unwrapResult(result);
46
46
  const length = vm.dump(handle);
47
47
  handle.dispose();
48
-
48
+
49
49
  expect(length).toBe(8);
50
50
  });
51
51
 
@@ -54,7 +54,7 @@ describe('crypto-utils shims tests', () => {
54
54
  const handle = vm.unwrapResult(result);
55
55
  const hexLength = vm.dump(handle);
56
56
  handle.dispose();
57
-
57
+
58
58
  expect(hexLength).toBe(8); // 4 bytes = 8 hex chars
59
59
  });
60
60
 
@@ -67,7 +67,7 @@ describe('crypto-utils shims tests', () => {
67
67
  const handle = vm.unwrapResult(result);
68
68
  const length = vm.dump(handle);
69
69
  handle.dispose();
70
-
70
+
71
71
  expect(length).toBe(5);
72
72
  });
73
- });
73
+ });
@@ -45,4 +45,4 @@ function deserializeTypedArray(obj) {
45
45
  module.exports = {
46
46
  serializeTypedArray,
47
47
  deserializeTypedArray
48
- }
48
+ };
@@ -7,7 +7,7 @@ const getResultsSummary = (results) => {
7
7
  total: results.length,
8
8
  passed: 0,
9
9
  failed: 0,
10
- skipped: 0,
10
+ skipped: 0
11
11
  };
12
12
 
13
13
  results.forEach((r) => {
@@ -34,7 +34,7 @@ const setupBruTestMethods = (bru, __brunoTestResults, assertionResults) => {
34
34
  const summary = getResultsSummary(results);
35
35
  return {
36
36
  summary,
37
- results: results.map(r => ({
37
+ results: results.map((r) => ({
38
38
  status: r.status,
39
39
  description: r.description,
40
40
  expected: r.expected,
@@ -49,7 +49,7 @@ const setupBruTestMethods = (bru, __brunoTestResults, assertionResults) => {
49
49
  const summary = getResultsSummary(results);
50
50
  return {
51
51
  summary,
52
- results: results.map(r => ({
52
+ results: results.map((r) => ({
53
53
  status: r.status,
54
54
  lhsExpr: r.lhsExpr,
55
55
  rhsExpr: r.rhsExpr,
@@ -77,4 +77,4 @@ module.exports = {
77
77
  getResultsSummary,
78
78
  createBruTestResultMethods,
79
79
  setupBruTestMethods
80
- };
80
+ };
package/src/utils.js CHANGED
@@ -90,7 +90,7 @@ const evaluateJsTemplateLiteral = (templateLiteral, context) => {
90
90
  return templateLiteral.slice(1, -1);
91
91
  }
92
92
 
93
- if (templateLiteral.startsWith("'") && templateLiteral.endsWith("'")) {
93
+ if (templateLiteral.startsWith('\'') && templateLiteral.endsWith('\'')) {
94
94
  return templateLiteral.slice(1, -1);
95
95
  }
96
96
 
@@ -129,7 +129,7 @@ const createResponseParser = (response = {}) => {
129
129
  };
130
130
 
131
131
  /**
132
- * Objects that are created inside vm2 execution context result in an serialization error when sent to the renderer process
132
+ * Objects that are created inside developer mode execution context result in an serialization error when sent to the renderer process
133
133
  * Error sending from webFrameMain: Error: Failed to serialize arguments
134
134
  * at s.send (node:electron/js2c/browser_init:169:631)
135
135
  * at g.send (node:electron/js2c/browser_init:165:2156)
@@ -201,7 +201,7 @@ const uuid = () => {
201
201
  const customNanoId = customAlphabet(urlAlphabet, 21);
202
202
 
203
203
  return customNanoId();
204
- }
204
+ };
205
205
 
206
206
  const appendAwaitToTestFunc = (str) => {
207
207
  return str.replace(/(?<!\.\s*)(?<!await\s)(test\()/g, 'await $1');
@@ -211,18 +211,18 @@ const cleanCircularJson = (data) => {
211
211
  try {
212
212
  // Handle circular references by keeping track of seen objects
213
213
  const seen = new WeakSet();
214
-
214
+
215
215
  const replacer = (key, value) => {
216
216
  // Skip non-objects and null
217
217
  if (typeof value !== 'object' || value === null) {
218
218
  return value;
219
219
  }
220
-
220
+
221
221
  // Detect circular reference
222
222
  if (seen.has(value)) {
223
223
  return '[Circular Reference]';
224
224
  }
225
-
225
+
226
226
  seen.add(value);
227
227
  return value;
228
228
  };