modestbench 0.5.1 → 0.6.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.
- package/CHANGELOG.md +7 -0
- package/dist/adapters/jest-adapter.cjs +496 -0
- package/dist/adapters/jest-adapter.cjs.map +1 -0
- package/dist/adapters/jest-adapter.d.cts +42 -0
- package/dist/adapters/jest-adapter.d.cts.map +1 -0
- package/dist/adapters/jest-adapter.d.ts +42 -0
- package/dist/adapters/jest-adapter.d.ts.map +1 -0
- package/dist/adapters/jest-adapter.js +459 -0
- package/dist/adapters/jest-adapter.js.map +1 -0
- package/dist/adapters/jest-hooks.cjs +83 -0
- package/dist/adapters/jest-hooks.cjs.map +1 -0
- package/dist/adapters/jest-hooks.d.cts +24 -0
- package/dist/adapters/jest-hooks.d.cts.map +1 -0
- package/dist/adapters/jest-hooks.d.ts +24 -0
- package/dist/adapters/jest-hooks.d.ts.map +1 -0
- package/dist/adapters/jest-hooks.js +78 -0
- package/dist/adapters/jest-hooks.js.map +1 -0
- package/dist/adapters/jest-register.cjs +17 -0
- package/dist/adapters/jest-register.cjs.map +1 -0
- package/dist/adapters/jest-register.d.cts +12 -0
- package/dist/adapters/jest-register.d.cts.map +1 -0
- package/dist/adapters/jest-register.d.ts +12 -0
- package/dist/adapters/jest-register.d.ts.map +1 -0
- package/dist/adapters/jest-register.js +15 -0
- package/dist/adapters/jest-register.js.map +1 -0
- package/dist/adapters/types.cjs.map +1 -1
- package/dist/adapters/types.d.cts +5 -1
- package/dist/adapters/types.d.cts.map +1 -1
- package/dist/adapters/types.d.ts +5 -1
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/adapters/types.js.map +1 -1
- package/dist/cli/commands/test.cjs +3 -0
- package/dist/cli/commands/test.cjs.map +1 -1
- package/dist/cli/commands/test.d.cts.map +1 -1
- package/dist/cli/commands/test.d.ts.map +1 -1
- package/dist/cli/commands/test.js +3 -0
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/index.cjs +2 -2
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/cli/index.js.map +1 -1
- package/package.json +26 -6
- package/src/adapters/jest-adapter.ts +563 -0
- package/src/adapters/jest-hooks.ts +82 -0
- package/src/adapters/jest-register.ts +16 -0
- package/src/adapters/types.ts +5 -1
- package/src/cli/commands/test.ts +3 -0
- package/src/cli/index.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.0](https://github.com/boneskull/modestbench/compare/modestbench-v0.5.1...modestbench-v0.6.0) (2025-12-13)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **adapters:** add Jest adapter with ESM loader hooks ([9a23066](https://github.com/boneskull/modestbench/commit/9a230665788d04da1487824a71bc8dfccb5212cc))
|
|
9
|
+
|
|
3
10
|
## [0.5.1](https://github.com/boneskull/modestbench/compare/modestbench-v0.5.0...modestbench-v0.5.1) (2025-12-11)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ModestBench Jest Adapter
|
|
4
|
+
*
|
|
5
|
+
* Captures test definitions from Jest test files using ES module loader hooks.
|
|
6
|
+
*
|
|
7
|
+
* Jest differs from AVA and node:test in important ways:
|
|
8
|
+
*
|
|
9
|
+
* - Nested describe blocks: describe() callbacks execute IMMEDIATELY during file
|
|
10
|
+
* load to discover nested tests. We must run describe callbacks but NOT test
|
|
11
|
+
* functions.
|
|
12
|
+
* - Rich API surface: .skip, .only, .each, .todo, .concurrent, .failing modifiers
|
|
13
|
+
* - Jest object: Tests may access jest.fn(), jest.mock(), etc.
|
|
14
|
+
* - Expect assertions: Tests use expect() for assertions
|
|
15
|
+
*
|
|
16
|
+
* Architecture:
|
|
17
|
+
*
|
|
18
|
+
* 1. Install mock on globalThis
|
|
19
|
+
* 2. Loader intercepts '@jest/globals' imports and returns the mock
|
|
20
|
+
* 3. Import test file - describe callbacks execute, test functions are captured
|
|
21
|
+
* 4. Return captured test structure
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
57
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
58
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
59
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return path;
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.JestAdapter = void 0;
|
|
66
|
+
const node_url_1 = require("node:url");
|
|
67
|
+
/**
|
|
68
|
+
* Global capture state key
|
|
69
|
+
*/
|
|
70
|
+
const CAPTURE_STATE_KEY = '__MODESTBENCH_JEST_CAPTURE__';
|
|
71
|
+
/**
|
|
72
|
+
* Get the current suite from the stack
|
|
73
|
+
*/
|
|
74
|
+
const getCurrentSuite = (state) => {
|
|
75
|
+
return state.suiteStack[state.suiteStack.length - 1] ?? state.rootSuite;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Jest test framework adapter
|
|
79
|
+
*
|
|
80
|
+
* Captures test definitions by installing mock implementations before importing
|
|
81
|
+
* the test file.
|
|
82
|
+
*
|
|
83
|
+
* IMPORTANT: For this to work with Jest imports, you must run Node.js with our
|
|
84
|
+
* loader: node --import modestbench/jest your-test.js
|
|
85
|
+
*/
|
|
86
|
+
class JestAdapter {
|
|
87
|
+
framework = 'jest';
|
|
88
|
+
/**
|
|
89
|
+
* Capture test definitions from a Jest test file
|
|
90
|
+
*
|
|
91
|
+
* @param filePath - Absolute path to the test file
|
|
92
|
+
* @returns Captured test structure
|
|
93
|
+
*/
|
|
94
|
+
async capture(filePath) {
|
|
95
|
+
// Initialize capture state
|
|
96
|
+
const state = initCaptureState();
|
|
97
|
+
// Install mocks
|
|
98
|
+
installJestMocks(state);
|
|
99
|
+
try {
|
|
100
|
+
// Import the test file
|
|
101
|
+
// The loader hook will intercept '@jest/globals' and use our mocks
|
|
102
|
+
// Describe callbacks will execute immediately, capturing the test structure
|
|
103
|
+
const fileUrl = (0, node_url_1.pathToFileURL)(filePath).href;
|
|
104
|
+
const bustCache = `?t=${Date.now()}`;
|
|
105
|
+
await Promise.resolve(`${__rewriteRelativeImportExtension(fileUrl + bustCache)}`).then(s => __importStar(require(s)));
|
|
106
|
+
// Return captured structure
|
|
107
|
+
return toCapturedTestFile(state, filePath);
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
// Clean up
|
|
111
|
+
uninstallJestMocks();
|
|
112
|
+
clearCaptureState();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.JestAdapter = JestAdapter;
|
|
117
|
+
/**
|
|
118
|
+
* Clear capture state from globalThis
|
|
119
|
+
*/
|
|
120
|
+
const clearCaptureState = () => {
|
|
121
|
+
// @ts-expect-error - intentionally using globalThis
|
|
122
|
+
delete globalThis[CAPTURE_STATE_KEY];
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Create a mock expect function
|
|
126
|
+
*
|
|
127
|
+
* Jest's expect() returns an object with assertion methods. We provide a stub
|
|
128
|
+
* that allows tests to call expect() without errors during structure capture.
|
|
129
|
+
* Since we capture but don't execute test functions, this is mainly for
|
|
130
|
+
* safety.
|
|
131
|
+
*/
|
|
132
|
+
const createMockExpect = () => {
|
|
133
|
+
const noop = () => mockExpect;
|
|
134
|
+
const noopAsync = () => Promise.resolve(mockExpect);
|
|
135
|
+
// Chainable assertion mock
|
|
136
|
+
const assertionChain = {
|
|
137
|
+
not: {},
|
|
138
|
+
rejects: {},
|
|
139
|
+
resolves: {},
|
|
140
|
+
};
|
|
141
|
+
// Common matchers - all return the chain for further chaining
|
|
142
|
+
const matchers = [
|
|
143
|
+
'toBe',
|
|
144
|
+
'toEqual',
|
|
145
|
+
'toStrictEqual',
|
|
146
|
+
'toBeNull',
|
|
147
|
+
'toBeUndefined',
|
|
148
|
+
'toBeDefined',
|
|
149
|
+
'toBeTruthy',
|
|
150
|
+
'toBeFalsy',
|
|
151
|
+
'toBeNaN',
|
|
152
|
+
'toContain',
|
|
153
|
+
'toContainEqual',
|
|
154
|
+
'toHaveLength',
|
|
155
|
+
'toHaveProperty',
|
|
156
|
+
'toMatch',
|
|
157
|
+
'toMatchObject',
|
|
158
|
+
'toMatchSnapshot',
|
|
159
|
+
'toMatchInlineSnapshot',
|
|
160
|
+
'toThrow',
|
|
161
|
+
'toThrowError',
|
|
162
|
+
'toThrowErrorMatchingSnapshot',
|
|
163
|
+
'toThrowErrorMatchingInlineSnapshot',
|
|
164
|
+
'toBeGreaterThan',
|
|
165
|
+
'toBeGreaterThanOrEqual',
|
|
166
|
+
'toBeLessThan',
|
|
167
|
+
'toBeLessThanOrEqual',
|
|
168
|
+
'toBeCloseTo',
|
|
169
|
+
'toBeInstanceOf',
|
|
170
|
+
'toHaveBeenCalled',
|
|
171
|
+
'toHaveBeenCalledTimes',
|
|
172
|
+
'toHaveBeenCalledWith',
|
|
173
|
+
'toHaveBeenLastCalledWith',
|
|
174
|
+
'toHaveBeenNthCalledWith',
|
|
175
|
+
'toHaveReturned',
|
|
176
|
+
'toHaveReturnedTimes',
|
|
177
|
+
'toHaveReturnedWith',
|
|
178
|
+
'toHaveLastReturnedWith',
|
|
179
|
+
'toHaveNthReturnedWith',
|
|
180
|
+
];
|
|
181
|
+
for (const matcher of matchers) {
|
|
182
|
+
assertionChain[matcher] = noop;
|
|
183
|
+
assertionChain.not[matcher] = noop;
|
|
184
|
+
assertionChain.resolves[matcher] = noopAsync;
|
|
185
|
+
assertionChain.rejects[matcher] = noopAsync;
|
|
186
|
+
}
|
|
187
|
+
const mockExpect = (_value) => assertionChain;
|
|
188
|
+
// Static expect methods
|
|
189
|
+
Object.assign(mockExpect, {
|
|
190
|
+
addSnapshotSerializer: noop,
|
|
191
|
+
any: noop,
|
|
192
|
+
anything: noop,
|
|
193
|
+
arrayContaining: noop,
|
|
194
|
+
assertions: noop,
|
|
195
|
+
closeTo: noop,
|
|
196
|
+
extend: noop,
|
|
197
|
+
getState: () => ({}),
|
|
198
|
+
hasAssertions: noop,
|
|
199
|
+
not: {
|
|
200
|
+
arrayContaining: noop,
|
|
201
|
+
objectContaining: noop,
|
|
202
|
+
stringContaining: noop,
|
|
203
|
+
stringMatching: noop,
|
|
204
|
+
},
|
|
205
|
+
objectContaining: noop,
|
|
206
|
+
setState: noop,
|
|
207
|
+
stringContaining: noop,
|
|
208
|
+
stringMatching: noop,
|
|
209
|
+
});
|
|
210
|
+
return mockExpect;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Create a mock jest object
|
|
214
|
+
*
|
|
215
|
+
* Provides stub implementations of common jest.* utilities that tests might
|
|
216
|
+
* call during structure capture. Since we don't execute test functions, most of
|
|
217
|
+
* these won't be called, but they're here for safety.
|
|
218
|
+
*/
|
|
219
|
+
const createMockJestObject = () => {
|
|
220
|
+
const noop = () => { };
|
|
221
|
+
const noopReturnsThis = function () {
|
|
222
|
+
return this;
|
|
223
|
+
};
|
|
224
|
+
// Mock function factory
|
|
225
|
+
const mockFn = (implementation) => {
|
|
226
|
+
const fn = typeof implementation === 'function' ? implementation : noop;
|
|
227
|
+
return Object.assign(fn, {
|
|
228
|
+
mock: { calls: [], instances: [], results: [] },
|
|
229
|
+
mockClear: noopReturnsThis,
|
|
230
|
+
mockImplementation: noopReturnsThis,
|
|
231
|
+
mockImplementationOnce: noopReturnsThis,
|
|
232
|
+
mockName: noopReturnsThis,
|
|
233
|
+
mockRejectedValue: noopReturnsThis,
|
|
234
|
+
mockRejectedValueOnce: noopReturnsThis,
|
|
235
|
+
mockReset: noopReturnsThis,
|
|
236
|
+
mockResolvedValue: noopReturnsThis,
|
|
237
|
+
mockResolvedValueOnce: noopReturnsThis,
|
|
238
|
+
mockRestore: noopReturnsThis,
|
|
239
|
+
mockReturnThis: noopReturnsThis,
|
|
240
|
+
mockReturnValue: noopReturnsThis,
|
|
241
|
+
mockReturnValueOnce: noopReturnsThis,
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
return {
|
|
245
|
+
advanceTimersByTime: noop,
|
|
246
|
+
advanceTimersByTimeAsync: () => Promise.resolve(),
|
|
247
|
+
advanceTimersToNextTimer: noop,
|
|
248
|
+
advanceTimersToNextTimerAsync: () => Promise.resolve(),
|
|
249
|
+
autoMockOff: noopReturnsThis,
|
|
250
|
+
autoMockOn: noopReturnsThis,
|
|
251
|
+
clearAllMocks: noop,
|
|
252
|
+
clearAllTimers: noop,
|
|
253
|
+
createMockFromModule: () => ({}),
|
|
254
|
+
deepUnmock: noopReturnsThis,
|
|
255
|
+
disableAutomock: noopReturnsThis,
|
|
256
|
+
doMock: noop,
|
|
257
|
+
dontMock: noopReturnsThis,
|
|
258
|
+
enableAutomock: noopReturnsThis,
|
|
259
|
+
fn: mockFn,
|
|
260
|
+
genMockFromModule: () => ({}),
|
|
261
|
+
getRealSystemTime: () => Date.now(),
|
|
262
|
+
getSeed: () => 0,
|
|
263
|
+
getTimerCount: () => 0,
|
|
264
|
+
isEnvironmentTornDown: () => false,
|
|
265
|
+
isMockFunction: () => false,
|
|
266
|
+
isolateModules: noop,
|
|
267
|
+
isolateModulesAsync: () => Promise.resolve(),
|
|
268
|
+
mock: noop,
|
|
269
|
+
mocked: (source) => source,
|
|
270
|
+
now: () => Date.now(),
|
|
271
|
+
replaceProperty: noopReturnsThis,
|
|
272
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-return -- Mimics Jest's requireActual API
|
|
273
|
+
requireActual: (moduleName) => require(moduleName),
|
|
274
|
+
requireMock: () => ({}),
|
|
275
|
+
resetAllMocks: noop,
|
|
276
|
+
resetModules: noopReturnsThis,
|
|
277
|
+
restoreAllMocks: noop,
|
|
278
|
+
retryTimes: noopReturnsThis,
|
|
279
|
+
runAllImmediates: noop,
|
|
280
|
+
runAllTicks: noop,
|
|
281
|
+
runAllTimers: noop,
|
|
282
|
+
runAllTimersAsync: () => Promise.resolve(),
|
|
283
|
+
runOnlyPendingTimers: noop,
|
|
284
|
+
runOnlyPendingTimersAsync: () => Promise.resolve(),
|
|
285
|
+
setMock: noopReturnsThis,
|
|
286
|
+
setSystemTime: noop,
|
|
287
|
+
setTimeout: noopReturnsThis,
|
|
288
|
+
spyOn: () => mockFn(),
|
|
289
|
+
unmock: noopReturnsThis,
|
|
290
|
+
unstable_mockModule: noop,
|
|
291
|
+
useFakeTimers: noopReturnsThis,
|
|
292
|
+
useRealTimers: noopReturnsThis,
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Initialize capture state on globalThis
|
|
297
|
+
*/
|
|
298
|
+
const initCaptureState = () => {
|
|
299
|
+
const rootSuite = {
|
|
300
|
+
children: [],
|
|
301
|
+
hooks: {
|
|
302
|
+
afterAll: [],
|
|
303
|
+
afterEach: [],
|
|
304
|
+
beforeAll: [],
|
|
305
|
+
beforeEach: [],
|
|
306
|
+
},
|
|
307
|
+
name: '',
|
|
308
|
+
tests: [],
|
|
309
|
+
};
|
|
310
|
+
const state = {
|
|
311
|
+
rootSuite,
|
|
312
|
+
suiteStack: [rootSuite],
|
|
313
|
+
};
|
|
314
|
+
// @ts-expect-error - intentionally using globalThis for cross-module state
|
|
315
|
+
globalThis[CAPTURE_STATE_KEY] = state;
|
|
316
|
+
return state;
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Install Jest mocks on globalThis for module interception
|
|
320
|
+
*/
|
|
321
|
+
const installJestMocks = (state) => {
|
|
322
|
+
const mockExpect = createMockExpect();
|
|
323
|
+
const mockJest = createMockJestObject();
|
|
324
|
+
/**
|
|
325
|
+
* Create a describe function implementation
|
|
326
|
+
*/
|
|
327
|
+
const makeDescribeFn = (options = {}) => (name, fn) => {
|
|
328
|
+
const suite = {
|
|
329
|
+
children: [],
|
|
330
|
+
hooks: {
|
|
331
|
+
afterAll: [],
|
|
332
|
+
afterEach: [],
|
|
333
|
+
beforeAll: [],
|
|
334
|
+
beforeEach: [],
|
|
335
|
+
},
|
|
336
|
+
name,
|
|
337
|
+
only: options.only,
|
|
338
|
+
skip: options.skip,
|
|
339
|
+
tests: [],
|
|
340
|
+
};
|
|
341
|
+
const currentSuite = getCurrentSuite(state);
|
|
342
|
+
currentSuite.children.push(suite);
|
|
343
|
+
// Push onto stack, execute callback to discover nested tests, then pop
|
|
344
|
+
state.suiteStack.push(suite);
|
|
345
|
+
try {
|
|
346
|
+
fn(); // Execute describe callback to discover nested content
|
|
347
|
+
}
|
|
348
|
+
finally {
|
|
349
|
+
state.suiteStack.pop();
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* Create a test function implementation
|
|
354
|
+
*/
|
|
355
|
+
const makeTestFn = (options = {}) => (name, fn, timeout) => {
|
|
356
|
+
const currentSuite = getCurrentSuite(state);
|
|
357
|
+
currentSuite.tests.push({
|
|
358
|
+
fn: fn ?? (() => { }),
|
|
359
|
+
name,
|
|
360
|
+
only: options.only,
|
|
361
|
+
skip: options.skip,
|
|
362
|
+
timeout,
|
|
363
|
+
});
|
|
364
|
+
};
|
|
365
|
+
// Create base describe function with modifiers
|
|
366
|
+
const describeFn = makeDescribeFn();
|
|
367
|
+
const describeOnly = makeDescribeFn({ only: true });
|
|
368
|
+
const describeSkip = makeDescribeFn({ skip: true });
|
|
369
|
+
const mockDescribe = Object.assign(describeFn, {
|
|
370
|
+
each: (table) => (nameTemplate, fn) => {
|
|
371
|
+
// Handle both array of arrays and template literal tagged syntax
|
|
372
|
+
const rows = Array.isArray(table[0]) ? table : [table];
|
|
373
|
+
for (const row of rows) {
|
|
374
|
+
// Simple template substitution for %s, %i, %d, %p, %j, etc.
|
|
375
|
+
let name = nameTemplate;
|
|
376
|
+
for (let i = 0; i < row.length; i++) {
|
|
377
|
+
name = name.replace(/%[sidpjfo#]/i, String(row[i]));
|
|
378
|
+
}
|
|
379
|
+
describeFn(name, () => fn(...row));
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
only: describeOnly,
|
|
383
|
+
skip: describeSkip,
|
|
384
|
+
});
|
|
385
|
+
// Create base test function with modifiers
|
|
386
|
+
const testFn = makeTestFn();
|
|
387
|
+
const testOnly = makeTestFn({ only: true });
|
|
388
|
+
const testSkip = makeTestFn({ skip: true });
|
|
389
|
+
const mockTest = Object.assign(testFn, {
|
|
390
|
+
concurrent: (name, fn, timeout) => {
|
|
391
|
+
// Treat concurrent tests as regular tests for benchmarking
|
|
392
|
+
testFn(name, fn, timeout);
|
|
393
|
+
},
|
|
394
|
+
each: (table) => (nameTemplate, fn, timeout) => {
|
|
395
|
+
const rows = Array.isArray(table[0]) ? table : [table];
|
|
396
|
+
for (const row of rows) {
|
|
397
|
+
let name = nameTemplate;
|
|
398
|
+
for (let i = 0; i < row.length; i++) {
|
|
399
|
+
name = name.replace(/%[sidpjfo#]/i, String(row[i]));
|
|
400
|
+
}
|
|
401
|
+
testFn(name, () => fn(...row), timeout);
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
failing: (name, fn, timeout) => {
|
|
405
|
+
// Treat failing tests as regular tests for benchmarking
|
|
406
|
+
testFn(name, fn, timeout);
|
|
407
|
+
},
|
|
408
|
+
only: testOnly,
|
|
409
|
+
skip: testSkip,
|
|
410
|
+
todo: (name) => {
|
|
411
|
+
const currentSuite = getCurrentSuite(state);
|
|
412
|
+
currentSuite.tests.push({
|
|
413
|
+
fn: () => { },
|
|
414
|
+
name,
|
|
415
|
+
skip: true,
|
|
416
|
+
});
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
// Hook registration helpers
|
|
420
|
+
const createHook = (hookType) => (fn, timeout) => {
|
|
421
|
+
const currentSuite = getCurrentSuite(state);
|
|
422
|
+
currentSuite.hooks[hookType].push({ fn, timeout });
|
|
423
|
+
};
|
|
424
|
+
// Install on globalThis for the loader to access
|
|
425
|
+
// @ts-expect-error - intentionally using globalThis
|
|
426
|
+
globalThis.__MODESTBENCH_JEST_MOCK__ = {
|
|
427
|
+
afterAll: createHook('afterAll'),
|
|
428
|
+
afterEach: createHook('afterEach'),
|
|
429
|
+
beforeAll: createHook('beforeAll'),
|
|
430
|
+
beforeEach: createHook('beforeEach'),
|
|
431
|
+
describe: mockDescribe,
|
|
432
|
+
expect: mockExpect,
|
|
433
|
+
fdescribe: mockDescribe.only,
|
|
434
|
+
fit: mockTest.only,
|
|
435
|
+
it: mockTest,
|
|
436
|
+
jest: mockJest,
|
|
437
|
+
test: mockTest,
|
|
438
|
+
xdescribe: mockDescribe.skip,
|
|
439
|
+
xit: mockTest.skip,
|
|
440
|
+
xtest: mockTest.skip,
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
/**
|
|
444
|
+
* Convert a mutable suite to the captured format
|
|
445
|
+
*/
|
|
446
|
+
const convertSuite = (suite) => {
|
|
447
|
+
const hooks = {
|
|
448
|
+
after: suite.hooks.afterAll.map((h) => h.fn),
|
|
449
|
+
afterEach: suite.hooks.afterEach.map((h) => h.fn),
|
|
450
|
+
before: suite.hooks.beforeAll.map((h) => h.fn),
|
|
451
|
+
beforeEach: suite.hooks.beforeEach.map((h) => h.fn),
|
|
452
|
+
};
|
|
453
|
+
const tests = suite.tests.map((t) => ({
|
|
454
|
+
fn: t.fn,
|
|
455
|
+
name: t.name,
|
|
456
|
+
only: t.only,
|
|
457
|
+
skip: t.skip,
|
|
458
|
+
}));
|
|
459
|
+
return {
|
|
460
|
+
children: suite.children.map(convertSuite),
|
|
461
|
+
hooks,
|
|
462
|
+
name: suite.name,
|
|
463
|
+
only: suite.only,
|
|
464
|
+
skip: suite.skip,
|
|
465
|
+
tests,
|
|
466
|
+
};
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* Convert capture state to CapturedTestFile
|
|
470
|
+
*/
|
|
471
|
+
const toCapturedTestFile = (state, filePath) => {
|
|
472
|
+
const root = state.rootSuite;
|
|
473
|
+
// Root-level tests (not in any describe block)
|
|
474
|
+
const rootTests = root.tests.map((t) => ({
|
|
475
|
+
fn: t.fn,
|
|
476
|
+
name: t.name,
|
|
477
|
+
only: t.only,
|
|
478
|
+
skip: t.skip,
|
|
479
|
+
}));
|
|
480
|
+
// Convert child suites
|
|
481
|
+
const rootSuites = root.children.map(convertSuite);
|
|
482
|
+
return {
|
|
483
|
+
filePath,
|
|
484
|
+
framework: 'jest',
|
|
485
|
+
rootSuites,
|
|
486
|
+
rootTests,
|
|
487
|
+
};
|
|
488
|
+
};
|
|
489
|
+
/**
|
|
490
|
+
* Uninstall Jest mocks
|
|
491
|
+
*/
|
|
492
|
+
const uninstallJestMocks = () => {
|
|
493
|
+
// @ts-expect-error - cleaning up globalThis
|
|
494
|
+
delete globalThis.__MODESTBENCH_JEST_MOCK__;
|
|
495
|
+
};
|
|
496
|
+
//# sourceMappingURL=jest-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-adapter.js","sourceRoot":"","sources":["../../src/adapters/jest-adapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyC;AAUzC;;GAEG;AACH,MAAM,iBAAiB,GAAG,8BAA8B,CAAC;AAkDzD;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,KAAmB,EAAwB,EAAE;IACpE,OAAO,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC;AAC1E,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAa,WAAW;IACb,SAAS,GAAG,MAAe,CAAC;IAErC;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CAAC,QAAgB;QAC5B,2BAA2B;QAC3B,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;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;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI;KACb,CAAC,CAAC,CAAC;IAEJ,OAAO;QACL,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC;QAC1C,KAAK;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,kBAAkB,GAAG,CACzB,KAAmB,EACnB,QAAgB,EACE,EAAE;IACpB,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC;IAE7B,+CAA+C;IAC/C,MAAM,SAAS,GAAmB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvD,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI;KACb,CAAC,CAAC,CAAC;IAEJ,uBAAuB;IACvB,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAEnD,OAAO;QACL,QAAQ;QACR,SAAS,EAAE,MAAM;QACjB,UAAU;QACV,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,kBAAkB,GAAG,GAAS,EAAE;IACpC,4CAA4C;IAC5C,OAAO,UAAU,CAAC,yBAAyB,CAAC;AAC9C,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModestBench Jest Adapter
|
|
3
|
+
*
|
|
4
|
+
* Captures test definitions from Jest test files using ES module loader hooks.
|
|
5
|
+
*
|
|
6
|
+
* Jest differs from AVA and node:test in important ways:
|
|
7
|
+
*
|
|
8
|
+
* - Nested describe blocks: describe() callbacks execute IMMEDIATELY during file
|
|
9
|
+
* load to discover nested tests. We must run describe callbacks but NOT test
|
|
10
|
+
* functions.
|
|
11
|
+
* - Rich API surface: .skip, .only, .each, .todo, .concurrent, .failing modifiers
|
|
12
|
+
* - Jest object: Tests may access jest.fn(), jest.mock(), etc.
|
|
13
|
+
* - Expect assertions: Tests use expect() for assertions
|
|
14
|
+
*
|
|
15
|
+
* Architecture:
|
|
16
|
+
*
|
|
17
|
+
* 1. Install mock on globalThis
|
|
18
|
+
* 2. Loader intercepts '@jest/globals' imports and returns the mock
|
|
19
|
+
* 3. Import test file - describe callbacks execute, test functions are captured
|
|
20
|
+
* 4. Return captured test structure
|
|
21
|
+
*/
|
|
22
|
+
import type { CapturedTestFile, TestFrameworkAdapter } from "./types.cjs";
|
|
23
|
+
/**
|
|
24
|
+
* Jest test framework adapter
|
|
25
|
+
*
|
|
26
|
+
* Captures test definitions by installing mock implementations before importing
|
|
27
|
+
* the test file.
|
|
28
|
+
*
|
|
29
|
+
* IMPORTANT: For this to work with Jest imports, you must run Node.js with our
|
|
30
|
+
* loader: node --import modestbench/jest your-test.js
|
|
31
|
+
*/
|
|
32
|
+
export declare class JestAdapter implements TestFrameworkAdapter {
|
|
33
|
+
readonly framework: "jest";
|
|
34
|
+
/**
|
|
35
|
+
* Capture test definitions from a Jest test file
|
|
36
|
+
*
|
|
37
|
+
* @param filePath - Absolute path to the test file
|
|
38
|
+
* @returns Captured test structure
|
|
39
|
+
*/
|
|
40
|
+
capture(filePath: string): Promise<CapturedTestFile>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=jest-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/jest-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAGV,gBAAgB,EAEhB,oBAAoB,EACrB,oBAAmB;AA8DpB;;;;;;;;GAQG;AACH,qBAAa,WAAY,YAAW,oBAAoB;IACtD,QAAQ,CAAC,SAAS,EAAG,MAAM,CAAU;IAErC;;;;;OAKG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAuB3D"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModestBench Jest Adapter
|
|
3
|
+
*
|
|
4
|
+
* Captures test definitions from Jest test files using ES module loader hooks.
|
|
5
|
+
*
|
|
6
|
+
* Jest differs from AVA and node:test in important ways:
|
|
7
|
+
*
|
|
8
|
+
* - Nested describe blocks: describe() callbacks execute IMMEDIATELY during file
|
|
9
|
+
* load to discover nested tests. We must run describe callbacks but NOT test
|
|
10
|
+
* functions.
|
|
11
|
+
* - Rich API surface: .skip, .only, .each, .todo, .concurrent, .failing modifiers
|
|
12
|
+
* - Jest object: Tests may access jest.fn(), jest.mock(), etc.
|
|
13
|
+
* - Expect assertions: Tests use expect() for assertions
|
|
14
|
+
*
|
|
15
|
+
* Architecture:
|
|
16
|
+
*
|
|
17
|
+
* 1. Install mock on globalThis
|
|
18
|
+
* 2. Loader intercepts '@jest/globals' imports and returns the mock
|
|
19
|
+
* 3. Import test file - describe callbacks execute, test functions are captured
|
|
20
|
+
* 4. Return captured test structure
|
|
21
|
+
*/
|
|
22
|
+
import type { CapturedTestFile, TestFrameworkAdapter } from "./types.js";
|
|
23
|
+
/**
|
|
24
|
+
* Jest test framework adapter
|
|
25
|
+
*
|
|
26
|
+
* Captures test definitions by installing mock implementations before importing
|
|
27
|
+
* the test file.
|
|
28
|
+
*
|
|
29
|
+
* IMPORTANT: For this to work with Jest imports, you must run Node.js with our
|
|
30
|
+
* loader: node --import modestbench/jest your-test.js
|
|
31
|
+
*/
|
|
32
|
+
export declare class JestAdapter implements TestFrameworkAdapter {
|
|
33
|
+
readonly framework: "jest";
|
|
34
|
+
/**
|
|
35
|
+
* Capture test definitions from a Jest test file
|
|
36
|
+
*
|
|
37
|
+
* @param filePath - Absolute path to the test file
|
|
38
|
+
* @returns Captured test structure
|
|
39
|
+
*/
|
|
40
|
+
capture(filePath: string): Promise<CapturedTestFile>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=jest-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/jest-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAGV,gBAAgB,EAEhB,oBAAoB,EACrB,mBAAmB;AA8DpB;;;;;;;;GAQG;AACH,qBAAa,WAAY,YAAW,oBAAoB;IACtD,QAAQ,CAAC,SAAS,EAAG,MAAM,CAAU;IAErC;;;;;OAKG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAuB3D"}
|