flake-monster 0.3.1 → 0.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flake-monster",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Source-to-source test hardener that injects async delays to surface flaky tests",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  import { fileURLToPath } from 'node:url';
2
2
  import { dirname, join, posix } from 'node:path';
3
3
  import { parseSource } from './parser.js';
4
- import { computeInjections, computeRuntimeImportInsertion, applyInsertions } from './injector.js';
4
+ import { computeInjections, computeRuntimeImportInsertion, applyInsertions, MARKER_PREFIX } from './injector.js';
5
5
  import { recoverDelays, scanForRecovery } from './remover.js';
6
6
 
7
7
  const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -43,6 +43,11 @@ export function createJavaScriptAdapter() {
43
43
  },
44
44
 
45
45
  inject(source, options) {
46
+ if (source.includes(MARKER_PREFIX)) {
47
+ console.warn(` Skipping ${options.filePath}: already injected (restore first)`);
48
+ return { source, points: [], runtimeNeeded: false };
49
+ }
50
+
46
51
  try {
47
52
  const { ast } = parseSource(source);
48
53
  const { insertions, points } = computeInjections(ast, source, options);
@@ -1,5 +1,15 @@
1
1
  import * as acorn from 'acorn';
2
- import { attachComments } from 'astravel';
2
+ import { defaultTraveler, attachComments } from 'astravel';
3
+
4
+ // Patch astravel bug: PropertyDefinition reuses MethodDefinition handler which
5
+ // calls this.go(node.value) without a null guard. Uninitialized class fields
6
+ // (e.g. `bar;`) have value: null, crashing the traversal.
7
+ defaultTraveler.PropertyDefinition = function (node, state) {
8
+ this.go(node.key, state);
9
+ if (node.value != null) {
10
+ this.go(node.value, state);
11
+ }
12
+ };
3
13
 
4
14
  /**
5
15
  * Parse JS source to ESTree AST with comments attached to nodes.