agent-docs 1.0.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.
Files changed (44) hide show
  1. package/.cursor/plans/OPTIMISE.md +379 -0
  2. package/.cursor/plans/VERSIONING.md +207 -0
  3. package/.cursor/rules/IMPORTANT.mdc +97 -0
  4. package/.github/ISSUE_TEMPLATE/bug_report.md +13 -0
  5. package/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
  6. package/.github/dependabot.yml +38 -0
  7. package/.github/pull_request_template.md +10 -0
  8. package/.github/workflows/format.yml +35 -0
  9. package/CODE_OF_CONDUCT.md +64 -0
  10. package/CONTRIBUTING.md +52 -0
  11. package/LICENSE.md +20 -0
  12. package/PLAN.md +707 -0
  13. package/README.md +133 -0
  14. package/SECURITY.md +21 -0
  15. package/docs/APEXANNOTATIONS.md +472 -0
  16. package/docs/APEXDOC.md +198 -0
  17. package/docs/CML.md +877 -0
  18. package/docs/CODEANALYZER.md +435 -0
  19. package/docs/CONTEXTDEFINITIONS.md +617 -0
  20. package/docs/ESLINT.md +827 -0
  21. package/docs/ESLINTJSDOC.md +520 -0
  22. package/docs/FIELDSERVICE.md +4452 -0
  23. package/docs/GRAPHBINARY.md +208 -0
  24. package/docs/GRAPHENGINE.md +616 -0
  25. package/docs/GRAPHML.md +337 -0
  26. package/docs/GRAPHSON.md +302 -0
  27. package/docs/GREMLIN.md +490 -0
  28. package/docs/GRYO.md +232 -0
  29. package/docs/HUSKY.md +106 -0
  30. package/docs/JEST.md +387 -0
  31. package/docs/JORJE.md +537 -0
  32. package/docs/JSDOC.md +621 -0
  33. package/docs/PMD.md +910 -0
  34. package/docs/PNPM.md +409 -0
  35. package/docs/PRETTIER.md +716 -0
  36. package/docs/PRETTIERAPEX.md +874 -0
  37. package/docs/REVENUETRANSACTIONMANAGEMENT.md +887 -0
  38. package/docs/TINKERPOP.md +252 -0
  39. package/docs/VITEST.md +706 -0
  40. package/docs/VSCODE.md +231 -0
  41. package/docs/XPATH31.md +213 -0
  42. package/package.json +32 -0
  43. package/postinstall.mjs +51 -0
  44. package/prettier.config.js +18 -0
package/docs/JEST.md ADDED
@@ -0,0 +1,387 @@
1
+ # Jest 30.0 Quick Reference for AI Agents
2
+
3
+ > **Version**: 1.0.0
4
+
5
+ Concise guide to Jest 30.0 APIs and features for AI coding assistants.
6
+
7
+ ## Globals
8
+
9
+ Jest provides global functions (no imports needed in JS, but required in TS):
10
+
11
+ - **`test(name, fn, timeout)`** / **`it(name, fn, timeout)`** - Define a test
12
+ - **`describe(name, fn)`** - Group related tests
13
+ - **`beforeAll(fn, timeout)`** - Run once before all tests
14
+ - **`afterAll(fn, timeout)`** - Run once after all tests
15
+ - **`beforeEach(fn, timeout)`** - Run before each test
16
+ - **`afterEach(fn, timeout)`** - Run after each test
17
+
18
+ **TypeScript imports:**
19
+
20
+ ```typescript
21
+ import { describe, expect, test } from '@jest/globals';
22
+ ```
23
+
24
+ **Modifiers:**
25
+
26
+ - **`.only`** - Run only this test/describe (e.g., `test.only`, `describe.only`)
27
+ - **`.skip`** - Skip this test/describe (e.g., `test.skip`, `describe.skip`)
28
+ - **`.todo(name)`** - Mark test as TODO (no implementation)
29
+
30
+ **`.each`** - Parameterized tests:
31
+
32
+ ```javascript
33
+ test.each([
34
+ [1, 2, 3],
35
+ [2, 3, 5],
36
+ ])('adds %i + %i = %i', (a, b, expected) => {
37
+ expect(a + b).toBe(expected);
38
+ });
39
+ ```
40
+
41
+ ## Expect API
42
+
43
+ **Basic matchers:**
44
+
45
+ - **`.toBe(value)`** - Strict equality (`===`)
46
+ - **`.toEqual(value)`** - Deep equality
47
+ - **`.toBeNull()`** - Matches `null`
48
+ - **`.toBeUndefined()`** - Matches `undefined`
49
+ - **`.toBeDefined()`** - Opposite of `toBeUndefined()`
50
+ - **`.toBeTruthy()`** - Truthy value
51
+ - **`.toBeFalsy()`** - Falsy value
52
+
53
+ **Number matchers:**
54
+
55
+ - **`.toBeGreaterThan(n)`** - `> n`
56
+ - **`.toBeGreaterThanOrEqual(n)`** - `>= n`
57
+ - **`.toBeLessThan(n)`** - `< n`
58
+ - **`.toBeLessThanOrEqual(n)`** - `<= n`
59
+ - **`.toBeCloseTo(n, numDigits?)`** - Floating point equality
60
+
61
+ **String matchers:**
62
+
63
+ - **`.toMatch(regexp | string)`** - String matches pattern
64
+ - **`.toContain(substring)`** - String contains substring
65
+
66
+ **Array/Object matchers:**
67
+
68
+ - **`.toContain(item)`** - Array contains item
69
+ - **`.toContainEqual(item)`** - Array contains equal item
70
+ - **`.toHaveLength(n)`** - Array/string length
71
+ - **`.toHaveProperty(keyPath, value?)`** - Object has property
72
+
73
+ **Exception matchers:**
74
+
75
+ - **`.toThrow(error?)`** - Function throws error
76
+ - **`.toThrowError(error?)`** - Alias for `toThrow`
77
+
78
+ **Promise matchers:**
79
+
80
+ - **`.resolves`** - Awaits promise resolution
81
+ - **`.rejects`** - Awaits promise rejection
82
+
83
+ ```javascript
84
+ await expect(promise).resolves.toBe(value);
85
+ await expect(promise).rejects.toThrow();
86
+ ```
87
+
88
+ **Mock matchers:**
89
+
90
+ - **`.toHaveBeenCalled()`** - Mock was called
91
+ - **`.toHaveBeenCalledTimes(n)`** - Called n times
92
+ - **`.toHaveBeenCalledWith(...args)`** - Called with args
93
+ - **`.toHaveBeenLastCalledWith(...args)`** - Last call args
94
+ - **`.toHaveBeenNthCalledWith(n, ...args)`** - Nth call args
95
+ - **`.toHaveReturned()`** - Mock returned (didn't throw)
96
+ - **`.toHaveReturnedWith(value)`** - Returned value
97
+ - **`.toHaveReturnedTimes(n)`** - Returned n times
98
+ - **`.toHaveLastReturnedWith(value)`** - Last return value
99
+ - **`.toHaveNthReturnedWith(n, value)`** - Nth return value
100
+
101
+ **Modifiers:**
102
+
103
+ - **`.not`** - Negate matcher: `expect(value).not.toBe(null)`
104
+ - **`.resolves`** - Unwrap promise: `await expect(promise).resolves.toBe(value)`
105
+ - **`.rejects`** - Unwrap rejection: `await expect(promise).rejects.toThrow()`
106
+
107
+ ## Mock Functions
108
+
109
+ **Creating mocks:**
110
+
111
+ - **`jest.fn(implementation?)`** - Create mock function
112
+ - **`jest.spyOn(object, methodName)`** - Spy on object method
113
+ - **`jest.spyOn(object, methodName, accessType?)`** - Spy on getter/setter
114
+ (`'get'` or `'set'`)
115
+
116
+ **Mock properties:**
117
+
118
+ - **`.mock.calls`** - Array of call arguments: `[[arg1, arg2], [arg3]]`
119
+ - **`.mock.results`** - Array of return values:
120
+ `[{type: 'return', value: x}, ...]`
121
+ - **`.mock.instances`** - Instances created with `new`
122
+ - **`.mock.contexts`** - `this` contexts for each call
123
+ - **`.mock.invocationCallOrder`** - Order of mock calls
124
+
125
+ **Mock implementations:**
126
+
127
+ - **`.mockImplementation(fn)`** - Set implementation
128
+ - **`.mockImplementationOnce(fn)`** - One-time implementation
129
+ - **`.mockReturnValue(value)`** - Return value
130
+ - **`.mockReturnValueOnce(value)`** - One-time return
131
+ - **`.mockResolvedValue(value)`** - Resolved promise
132
+ - **`.mockResolvedValueOnce(value)`** - One-time resolved
133
+ - **`.mockRejectedValue(value)`** - Rejected promise
134
+ - **`.mockRejectedValueOnce(value)`** - One-time rejected
135
+ - **`.mockReset()`** - Clear calls/instances (keeps implementation)
136
+ - **`.mockRestore()`** - Restore original (spies only)
137
+ - **`.mockClear()`** - Clear calls/instances/results
138
+
139
+ ## Jest Object
140
+
141
+ **Module mocking:**
142
+
143
+ - **`jest.mock(moduleName, factory?, options?)`** - Mock module
144
+ - **`jest.unmock(moduleName)`** - Unmock module
145
+ - **`jest.doMock(moduleName, factory?, options?)`** - Mock (hoisted)
146
+ - **`jest.dontMock(moduleName)`** - Don't mock
147
+ - **`jest.requireActual(moduleName)`** - Get actual module
148
+ - **`jest.requireMock(moduleName)`** - Get mocked module
149
+
150
+ **Mock management:**
151
+
152
+ - **`jest.clearAllMocks()`** - Clear all mocks (calls/instances)
153
+ - **`jest.resetAllMocks()`** - Reset all mocks (calls/instances/implementations)
154
+ - **`jest.restoreAllMocks()`** - Restore all spies
155
+
156
+ **Timers:**
157
+
158
+ - **`jest.useFakeTimers()`** - Use fake timers
159
+ - **`jest.useRealTimers()`** - Use real timers
160
+ - **`jest.advanceTimersByTime(ms)`** - Advance timers
161
+ - **`jest.runOnlyPendingTimers()`** - Run pending timers
162
+ - **`jest.runAllTimers()`** - Run all timers
163
+ - **`jest.runAllImmediates()`** - Run all immediates
164
+ - **`jest.advanceTimersToNextTimer()`** - Advance to next timer
165
+ - **`jest.clearAllTimers()`** - Clear all timers
166
+ - **`jest.getTimerCount()`** - Get timer count
167
+ - **`jest.setSystemTime(now)`** - Set system time
168
+ - **`jest.getRealSystemTime()`** - Get real system time
169
+
170
+ **Other:**
171
+
172
+ - **`jest.setTimeout(timeout)`** - Set test timeout
173
+ - **`jest.retryTimes(numRetries, options?)`** - Retry failed tests
174
+
175
+ ## Configuration
176
+
177
+ **Config file:** `jest.config.js` or `jest` key in `package.json`
178
+
179
+ **Common options:**
180
+
181
+ - **`testEnvironment`** - `'node'` | `'jsdom'` | `'jest-environment-node'`
182
+ - **`testMatch`** - Array of glob patterns: `['**/__tests__/**/*.js']`
183
+ - **`testPathIgnorePatterns`** - Array of regex patterns to ignore
184
+ - **`collectCoverage`** - Collect coverage (or `--coverage` CLI)
185
+ - **`coverageDirectory`** - Coverage output directory
186
+ - **`coverageReporters`** - `['text', 'lcov', 'html']`
187
+ - **`collectCoverageFrom`** - Array of glob patterns
188
+ - **`verbose`** - Show individual test results
189
+ - **`bail`** - Stop after first failure (or number)
190
+ - **`testTimeout`** - Default timeout (ms)
191
+ - **`roots`** - Array of root directories
192
+ - **`moduleNameMapper`** - Map module paths: `{'^@/(.*)$': '<rootDir>/src/$1'}`
193
+ - **`transform`** - Transform config: `{'^.+\\.js$': 'babel-jest'}`
194
+ - **`transformIgnorePatterns`** - Patterns to skip transformation
195
+ - **`setupFilesAfterEnv`** - Array of setup files
196
+ - **`testEnvironmentOptions`** - Options for test environment
197
+
198
+ **Example:**
199
+
200
+ ```javascript
201
+ module.exports = {
202
+ testEnvironment: 'node',
203
+ testMatch: ['**/tests/**/*.test.js'],
204
+ collectCoverageFrom: ['src/**/*.js'],
205
+ coverageDirectory: 'coverage',
206
+ verbose: true,
207
+ testTimeout: 10000,
208
+ };
209
+ ```
210
+
211
+ ## CLI Options
212
+
213
+ **Common flags:**
214
+
215
+ - **`--watch`** / **`-w`** - Watch mode
216
+ - **`--coverage`** - Collect coverage
217
+ - **`--runInBand`** / **`-i`** - Run serially (no workers)
218
+ - **`--testNamePattern=<pattern>`** / **`-t`** - Run matching tests
219
+ - **`--testPathPattern=<pattern>`** - Run matching paths
220
+ - **`--verbose`** - Show individual test results
221
+ - **`--silent`** - Suppress console output
222
+ - **`--bail`** - Stop after first failure
223
+ - **`--maxWorkers=<num>`** - Number of workers
224
+ - **`--detectOpenHandles`** - Detect open handles
225
+ - **`--forceExit`** - Force exit after tests
226
+ - **`--config=<path>`** - Config file path
227
+ - **`--updateSnapshot`** / **`-u`** - Update snapshots
228
+ - **`--clearCache`** - Clear cache
229
+
230
+ **Examples:**
231
+
232
+ ```bash
233
+ jest --watch
234
+ jest --coverage
235
+ jest --testNamePattern="should detect"
236
+ jest --testPathPattern="code-style"
237
+ ```
238
+
239
+ ## Environment Variables
240
+
241
+ - **`NODE_ENV`** - Usually set to `'test'`
242
+ - **`CI`** - Set in CI environments
243
+ - **`JEST_WORKER_ID`** - Worker process ID
244
+ - **`TZ`** - Timezone (affects date tests)
245
+
246
+ ## Code Transformation
247
+
248
+ **Transformers:**
249
+
250
+ - **`babel-jest`** - Babel transformation
251
+ - **`ts-jest`** - TypeScript transformation
252
+ - **Custom transformer** - Function or module path
253
+
254
+ **Configuration:**
255
+
256
+ ```javascript
257
+ module.exports = {
258
+ transform: {
259
+ '^.+\\.js$': 'babel-jest',
260
+ '^.+\\.ts$': 'ts-jest',
261
+ },
262
+ transformIgnorePatterns: ['node_modules/(?!(module-to-transform)/)'],
263
+ };
264
+ ```
265
+
266
+ **Transformer function:**
267
+
268
+ ```javascript
269
+ module.exports = {
270
+ transform: {
271
+ '^.+\\.custom$': (src, filename, config, options) => {
272
+ return transformedCode;
273
+ },
274
+ },
275
+ };
276
+ ```
277
+
278
+ ## Best Practices
279
+
280
+ 1. **Use `describe` blocks** to organize related tests
281
+ 2. **Use descriptive test names** that explain what is being tested
282
+ 3. **One assertion per test** (when possible) for clarity
283
+ 4. **Use `beforeEach`/`afterEach`** for test isolation
284
+ 5. **Mock external dependencies** with `jest.fn()` or `jest.spyOn()`
285
+ 6. **Use `async`/`await`** for async tests
286
+ 7. **Clean up mocks** with `jest.clearAllMocks()` in `afterEach`
287
+ 8. **Use `test.each`** for parameterized tests
288
+ 9. **Set appropriate timeouts** for slow tests
289
+ 10. **Use `--watch`** during development
290
+
291
+ ## Common Patterns
292
+
293
+ **Async test:**
294
+
295
+ ```javascript
296
+ test('async operation', async () => {
297
+ const result = await asyncFunction();
298
+ expect(result).toBe(expected);
299
+ });
300
+ ```
301
+
302
+ **Mocking modules:**
303
+
304
+ ```javascript
305
+ jest.mock('./module', () => ({
306
+ functionName: jest.fn(),
307
+ }));
308
+ ```
309
+
310
+ **Spying on methods:**
311
+
312
+ ```javascript
313
+ const spy = jest.spyOn(object, 'method');
314
+ // ... test code ...
315
+ spy.mockRestore();
316
+ ```
317
+
318
+ **Testing errors:**
319
+
320
+ ```javascript
321
+ expect(() => {
322
+ throwError();
323
+ }).toThrow('Error message');
324
+ ```
325
+
326
+ **Testing promises:**
327
+
328
+ ```javascript
329
+ await expect(asyncFunction()).resolves.toBe(value);
330
+ await expect(asyncFunction()).rejects.toThrow();
331
+ ```
332
+
333
+ ## Troubleshooting
334
+
335
+ ### Node.js 25 `--localstorage-file` Warning
336
+
337
+ **Issue:** When running Jest tests with Node.js 25+, you may see the following
338
+ warning:
339
+
340
+ ```
341
+ (node:xxxxx) Warning: `--localstorage-file` was provided without a valid path
342
+ ```
343
+
344
+ **Root Cause:** Jest's Node environment (`jest-environment-node`) accesses
345
+ Node.js's webstorage API during test teardown. Node.js 25 requires the
346
+ `--localstorage-file` flag to have a valid path when webstorage is accessed.
347
+
348
+ **Solution:** Provide a valid path for the `--localstorage-file` flag by setting
349
+ `NODE_OPTIONS` in your test scripts:
350
+
351
+ ```json
352
+ {
353
+ "scripts": {
354
+ "test": "NODE_OPTIONS='--localstorage-file=.jest-localstorage' jest",
355
+ "test:watch": "NODE_OPTIONS='--localstorage-file=.jest-localstorage' jest --watch",
356
+ "test:coverage": "NODE_OPTIONS='--localstorage-file=.jest-localstorage' jest --coverage"
357
+ }
358
+ }
359
+ ```
360
+
361
+ **Additional Steps:**
362
+
363
+ 1. Add `.jest-localstorage` to your `.gitignore` file to prevent committing the
364
+ temporary file:
365
+
366
+ ```
367
+ .jest-localstorage
368
+ ```
369
+
370
+ 2. The file will be automatically created by Node.js when Jest accesses the
371
+ webstorage API.
372
+
373
+ **Stack Trace Location:** The warning originates from:
374
+
375
+ - `node:internal/webstorage:32:25` - Node.js webstorage module
376
+ - `jest-util/build/index.js:417:59` - `deleteProperties` function
377
+ - `jest-environment-node/build/index.js:265:40` - `GlobalProxy.clear` method
378
+ - `jest-environment-node/build/index.js:213:23` - `NodeEnvironment.teardown`
379
+ method
380
+
381
+ **Verification:** To trace the warning source, use:
382
+
383
+ ```bash
384
+ NODE_OPTIONS='--trace-warnings' pnpm test
385
+ ```
386
+
387
+ This will show the full stack trace indicating where the warning originates.