@zohodesk/testinglibrary 0.1.9-exp-actors → 0.1.12-experimental
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/.babelrc +4 -2
- package/.claude/settings.local.json +14 -0
- package/.gitlab-ci.yml +206 -0
- package/README.md +264 -1
- package/build/common/data-generator/steps/DataGenerator.spec.js +19 -0
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +21 -0
- package/build/common/multi-actor/steps/multiActorHandling.spec.js +26 -0
- package/build/common/searchFake/helpers/rpcRequestHelper.js +52 -0
- package/build/common/searchFake/steps/searchFake.spec.js +85 -0
- package/build/core/dataGenerator/DataGenerator.js +161 -0
- package/build/core/dataGenerator/DataGeneratorError.js +60 -0
- package/build/core/dataGenerator/DataGeneratorHelper.js +121 -0
- package/build/core/dataGenerator/authenticator/Authenticator.js +37 -0
- package/build/core/dataGenerator/authenticator/CookieAuthenticator.js +48 -0
- package/build/core/dataGenerator/authenticator/JWTauthenticator.js +59 -0
- package/build/core/dataGenerator/authenticator/OAuthAuthenticator.js +26 -0
- package/build/core/dataGenerator/authenticator/OrgOAuthAuthenticator.js +26 -0
- package/build/core/dataGenerator/authenticator/cookieAuthConfig.js +11 -0
- package/build/core/jest/preprocessor/jsPreprocessor.js +2 -7
- package/build/core/jest/setup/index.js +1 -7
- package/build/core/playwright/builtInFixtures/actorContext.js +78 -0
- package/build/core/playwright/builtInFixtures/caseTimeout.js +20 -0
- package/build/core/playwright/builtInFixtures/context.js +34 -16
- package/build/core/playwright/builtInFixtures/executionContext.js +17 -0
- package/build/core/playwright/builtInFixtures/i18N.js +8 -0
- package/build/core/playwright/builtInFixtures/index.js +7 -1
- package/build/core/playwright/builtInFixtures/page.js +22 -84
- package/build/core/playwright/clear-caches.js +17 -5
- package/build/core/playwright/codegen.js +4 -21
- package/build/core/playwright/configuration/Configuration.js +25 -0
- package/build/core/playwright/configuration/ConfigurationHelper.js +45 -0
- package/build/core/playwright/configuration/UserArgs.js +12 -0
- package/build/core/playwright/constants/configConstants.js +17 -0
- package/build/core/playwright/constants/failureTagConstants.js +17 -0
- package/build/core/playwright/constants/fileMutexConfig.js +9 -0
- package/build/core/playwright/constants/reporterConstants.js +20 -0
- package/build/core/playwright/constants/retryConstants.js +8 -0
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/env-initializer.js +26 -7
- package/build/core/playwright/fixtures.js +24 -0
- package/build/core/playwright/helpers/additionalProfiles.js +25 -0
- package/build/core/playwright/helpers/auth/accountLogin.js +4 -1
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +20 -19
- package/build/core/playwright/helpers/auth/getUsers.js +57 -49
- package/build/core/playwright/helpers/auth/index.js +14 -1
- package/build/core/playwright/helpers/auth/loginDefaultStepsHelper.js +62 -0
- package/build/core/playwright/helpers/auth/loginSteps.js +40 -22
- package/build/core/playwright/helpers/browserTimeoutFactor.js +16 -0
- package/build/core/playwright/helpers/caseTimeoutResolver.js +37 -0
- package/build/core/playwright/helpers/checkAuthDirectory.js +27 -0
- package/build/core/playwright/helpers/configFileNameProvider.js +21 -7
- package/build/core/playwright/helpers/configPathResolver.js +38 -0
- package/build/core/playwright/helpers/contextFailureHandler.js +81 -0
- package/build/core/playwright/helpers/customFixturesHelper.js +58 -0
- package/build/core/playwright/helpers/failureTagClassifier.js +197 -0
- package/build/core/playwright/helpers/fileMutex.js +71 -0
- package/build/core/playwright/helpers/logCollector.js +147 -0
- package/build/core/playwright/helpers/parseUserArgs.js +2 -3
- package/build/core/playwright/helpers/runtimeLogAnnotator.js +140 -0
- package/build/core/playwright/helpers/runtimeLogPath.js +61 -0
- package/build/core/playwright/helpers/runtimeLogReader.js +54 -0
- package/build/core/playwright/helpers/thirdPartyLib.js +13 -0
- package/build/core/playwright/index.js +8 -88
- package/build/core/playwright/patterns/casePatterns.js +9 -0
- package/build/core/playwright/patterns/codePatterns.js +9 -0
- package/build/core/playwright/patterns/environmentPatterns.js +15 -0
- package/build/core/playwright/patterns/index.js +33 -0
- package/build/core/playwright/patterns/logCollectorIgnorePatterns.js +15 -0
- package/build/core/playwright/patterns/toolPatterns.js +26 -0
- package/build/core/playwright/readConfigFile.js +49 -16
- package/build/core/playwright/reporter/PlaywrightReporter.js +58 -0
- package/build/core/playwright/reporter/Reporter.js +65 -0
- package/build/core/playwright/reporter/ShardReporter.js +58 -0
- package/build/core/playwright/reporter/UnitReporter.js +27 -0
- package/build/core/playwright/reporter/helpers/mergeAbortedTests.js +78 -0
- package/build/core/playwright/runner/Runner.js +22 -0
- package/build/core/playwright/runner/RunnerHelper.js +43 -0
- package/build/core/playwright/runner/RunnerTypes.js +17 -0
- package/build/core/playwright/runner/SpawnRunner.js +93 -0
- package/build/core/playwright/setup/Project.js +35 -0
- package/build/core/playwright/setup/ProjectConfiguration.js +66 -0
- package/build/core/playwright/setup/config-creator.js +58 -40
- package/build/core/playwright/setup/config-utils.js +68 -37
- package/build/core/playwright/setup/custom-reporter.js +137 -14
- package/build/core/playwright/setup/merge-config.js +32 -0
- package/build/core/playwright/setup/qc-custom-reporter.js +342 -0
- package/build/core/playwright/spawnInheritChild.js +71 -0
- package/build/core/playwright/tagProcessor.js +69 -0
- package/build/core/playwright/test-runner.js +44 -97
- package/build/core/playwright/types.js +4 -1
- package/build/core/playwright/validateFeature.js +28 -0
- package/build/decorators.d.ts +1 -1
- package/build/decorators.js +1 -1
- package/build/index.d.ts +2 -22
- package/build/index.js +12 -2
- package/build/lib/cli.js +42 -7
- package/build/setup-folder-structure/helper.js +2 -0
- package/build/setup-folder-structure/samples/accountLogin-sample.js +19 -0
- package/build/setup-folder-structure/samples/actors-index.js +2 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +10 -66
- package/build/setup-folder-structure/samples/editions-index.js +3 -0
- package/build/setup-folder-structure/samples/free-sample.json +25 -0
- package/build/setup-folder-structure/samples/settings.json +7 -0
- package/build/setup-folder-structure/samples/testSetup-sample.js +14 -0
- package/build/setup-folder-structure/samples/uat-config-sample.js +7 -2
- package/build/setup-folder-structure/setupProject.js +23 -5
- package/build/test/core/dataGenerator/__tests__/DataGenerator.test.js +311 -0
- package/build/test/core/dataGenerator/__tests__/DataGeneratorHelper.test.js +204 -0
- package/build/test/core/dataGenerator/__tests__/DataGeneratorResolution.test.js +126 -0
- package/build/test/core/dataGenerator/authenticator/__tests__/Authenticator.test.js +88 -0
- package/build/test/core/dataGenerator/authenticator/__tests__/JWTauthenticator.test.js +136 -0
- package/build/test/core/dataGenerator/authenticator/__tests__/OAuthAuthenticator.test.js +39 -0
- package/build/test/core/dataGenerator/authenticator/__tests__/OrgOAuthAuthenticator.test.js +39 -0
- package/build/test/core/playwright/__tests__/spawnInheritChild.test.js +148 -0
- package/build/test/core/playwright/__tests__/tagProcessor.test.js +94 -0
- package/build/test/core/playwright/__tests__/validateFeature.test.js +72 -0
- package/build/test/core/playwright/buildInFixtures/__tests__/caseTimeout.test.js +96 -0
- package/build/test/core/playwright/buildInFixtures/__tests__/executionContext.test.js +27 -0
- package/build/test/core/playwright/configuration/__tests__/Configuration.test.js +53 -0
- package/build/test/core/playwright/helpers/__tests__/additionalProfiles.test.js +45 -0
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +75 -0
- package/build/test/core/playwright/helpers/__tests__/configPathResolver.test.js +55 -0
- package/build/test/core/playwright/helpers/__tests__/customFixturesHelper.test.js +51 -0
- package/build/test/core/playwright/helpers/__tests__/failureTagClassifier.test.js +604 -0
- package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +79 -0
- package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +83 -0
- package/build/test/core/playwright/helpers/__tests__/logCollector.test.js +163 -0
- package/build/test/core/playwright/helpers/__tests__/runtimeLogReader.test.js +112 -0
- package/build/test/core/playwright/helpers/auth/__tests__/checkAuthCookies.test.js +92 -0
- package/build/test/core/playwright/runner/__tests__/RunnerHelper.test.js +19 -0
- package/build/test/core/playwright/runner/__tests__/SpawnRunner.test.js +30 -0
- package/build/utils/cliArgsToObject.js +3 -0
- package/build/utils/commonUtils.js +20 -0
- package/build/utils/fileUtils.js +43 -1
- package/build/utils/logger.js +1 -30
- package/changelog.md +23 -0
- package/docs/CODE-REVIEW-AGENT.md +399 -0
- package/docs/code-review-instructions.md +157 -0
- package/jest.config.js +29 -11
- package/npm-shrinkwrap.json +14994 -4793
- package/package.json +39 -28
- package/playwright.config.js +13 -57
- package/unit_reports/unit-report.html +277 -0
- package/build/bdd-framework/cli/commands/env.js +0 -42
- package/build/bdd-framework/cli/commands/export.js +0 -47
- package/build/bdd-framework/cli/commands/test.js +0 -64
- package/build/bdd-framework/cli/index.js +0 -11
- package/build/bdd-framework/cli/options.js +0 -19
- package/build/bdd-framework/cli/worker.js +0 -13
- package/build/bdd-framework/config/configDir.js +0 -35
- package/build/bdd-framework/config/enrichReporterData.js +0 -23
- package/build/bdd-framework/config/env.js +0 -50
- package/build/bdd-framework/config/index.js +0 -94
- package/build/bdd-framework/config/lang.js +0 -14
- package/build/bdd-framework/cucumber/buildStepDefinition.js +0 -43
- package/build/bdd-framework/cucumber/createTestStep.js +0 -43
- package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +0 -126
- package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +0 -72
- package/build/bdd-framework/cucumber/formatter/PickleParser.js +0 -25
- package/build/bdd-framework/cucumber/formatter/durationHelpers.js +0 -13
- package/build/bdd-framework/cucumber/formatter/getColorFns.js +0 -57
- package/build/bdd-framework/cucumber/formatter/index.js +0 -16
- package/build/bdd-framework/cucumber/formatter/locationHelpers.js +0 -16
- package/build/bdd-framework/cucumber/loadConfig.js +0 -17
- package/build/bdd-framework/cucumber/loadFeatures.js +0 -70
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +0 -20
- package/build/bdd-framework/cucumber/loadSteps.js +0 -47
- package/build/bdd-framework/cucumber/resolveFeaturePaths.js +0 -62
- package/build/bdd-framework/cucumber/stepArguments.js +0 -21
- package/build/bdd-framework/cucumber/types.js +0 -5
- package/build/bdd-framework/cucumber/valueChecker.js +0 -23
- package/build/bdd-framework/decorators.js +0 -18
- package/build/bdd-framework/gen/fixtures.js +0 -48
- package/build/bdd-framework/gen/formatter.js +0 -123
- package/build/bdd-framework/gen/i18n.js +0 -39
- package/build/bdd-framework/gen/index.js +0 -185
- package/build/bdd-framework/gen/testFile.js +0 -465
- package/build/bdd-framework/gen/testMeta.js +0 -60
- package/build/bdd-framework/gen/testNode.js +0 -60
- package/build/bdd-framework/gen/testPoms.js +0 -133
- package/build/bdd-framework/hooks/scenario.js +0 -130
- package/build/bdd-framework/hooks/worker.js +0 -89
- package/build/bdd-framework/index.js +0 -52
- package/build/bdd-framework/playwright/fixtureParameterNames.js +0 -93
- package/build/bdd-framework/playwright/getLocationInFile.js +0 -79
- package/build/bdd-framework/playwright/loadConfig.js +0 -42
- package/build/bdd-framework/playwright/loadUtils.js +0 -33
- package/build/bdd-framework/playwright/testTypeImpl.js +0 -61
- package/build/bdd-framework/playwright/transform.js +0 -88
- package/build/bdd-framework/playwright/types.js +0 -5
- package/build/bdd-framework/playwright/utils.js +0 -34
- package/build/bdd-framework/reporter/cucumber/base.js +0 -57
- package/build/bdd-framework/reporter/cucumber/custom.js +0 -73
- package/build/bdd-framework/reporter/cucumber/helper.js +0 -12
- package/build/bdd-framework/reporter/cucumber/html.js +0 -35
- package/build/bdd-framework/reporter/cucumber/index.js +0 -74
- package/build/bdd-framework/reporter/cucumber/json.js +0 -312
- package/build/bdd-framework/reporter/cucumber/junit.js +0 -205
- package/build/bdd-framework/reporter/cucumber/message.js +0 -20
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +0 -64
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +0 -196
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +0 -43
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +0 -52
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +0 -105
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +0 -70
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +0 -45
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +0 -27
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +0 -38
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +0 -128
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +0 -126
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +0 -102
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +0 -50
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +0 -88
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +0 -30
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwUtils.js +0 -51
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +0 -35
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +0 -5
- package/build/bdd-framework/run/StepInvoker.js +0 -68
- package/build/bdd-framework/run/bddDataAttachment.js +0 -46
- package/build/bdd-framework/run/bddFixtures.js +0 -191
- package/build/bdd-framework/run/bddWorld.js +0 -79
- package/build/bdd-framework/run/bddWorldInternal.js +0 -15
- package/build/bdd-framework/snippets/index.js +0 -132
- package/build/bdd-framework/snippets/snippetSyntax.js +0 -43
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +0 -26
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +0 -18
- package/build/bdd-framework/stepDefinitions/createBdd.js +0 -66
- package/build/bdd-framework/stepDefinitions/decorators/class.js +0 -68
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +0 -99
- package/build/bdd-framework/stepDefinitions/defineStep.js +0 -62
- package/build/bdd-framework/stepDefinitions/stepConfig.js +0 -24
- package/build/bdd-framework/utils/AutofillMap.js +0 -20
- package/build/bdd-framework/utils/exit.js +0 -62
- package/build/bdd-framework/utils/index.js +0 -93
- package/build/bdd-framework/utils/jsStringWrap.js +0 -44
- package/build/bdd-framework/utils/logger.js +0 -30
- package/build/bdd-framework/utils/stripAnsiEscapes.js +0 -20
- package/build/core/playwright/report-generator.js +0 -42
- package/build/core/playwright/tag-processor.js +0 -68
- package/build/setup-folder-structure/samples/authUsers-sample.json +0 -9
- package/build/setup-folder-structure/samples/env-config-sample.json +0 -21
package/changelog.md
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
# Testing Framework
|
|
2
2
|
|
|
3
3
|
## Framework that abstracts the configuration for playwright and Jest
|
|
4
|
+
# 0.2.4
|
|
5
|
+
- Issue fixes on custom fixtures
|
|
6
|
+
- Page Fixture
|
|
7
|
+
- i18n Fixture
|
|
8
|
+
|
|
9
|
+
# 0.2.1
|
|
10
|
+
**Issue Fixes**
|
|
11
|
+
- Fixes issue in actors configuration
|
|
12
|
+
- Added Error Logger
|
|
13
|
+
|
|
14
|
+
# 0.2.0
|
|
15
|
+
**Major Breaking Change**
|
|
16
|
+
- Removed Env-config.json in favour of conf/*/settings.json
|
|
17
|
+
- Mode in uat.config.js is deprecated. Use command args instead
|
|
18
|
+
|
|
19
|
+
**Enhancements**
|
|
20
|
+
- Playwright version updated to 1.42.1
|
|
21
|
+
- Playwright-bdd version updated to 6.1.1
|
|
22
|
+
- Tags Support
|
|
23
|
+
- Added getMetaInfo fixture to get the actors Info data
|
|
24
|
+
|
|
25
|
+
**Issue Fixes**
|
|
26
|
+
- Fixes #10- Mode config not working properly
|
|
4
27
|
|
|
5
28
|
# 0.1.9
|
|
6
29
|
**Enhancements**
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
# Code Review Agent
|
|
2
|
+
|
|
3
|
+
> **VS Code setup:** Copy this file to your repo as `.github/copilot-instructions.md`,
|
|
4
|
+
> or save it anywhere and reference it in **GitHub Copilot Chat** with `@workspace` or by attaching the file.
|
|
5
|
+
> **Trigger phrase:** *"Review my code using the Code Review Agent"*
|
|
6
|
+
|
|
7
|
+
You are a senior software reviewer helping a developer and their mentees ship safe, maintainable code in **any programming language**. Review **only the changed code** unless the user asks for a full-file or repo review.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Workflow
|
|
12
|
+
|
|
13
|
+
1. **Detect language** — Infer from file extension, syntax, and project config (`package.json`, `go.mod`, `pyproject.toml`, `pom.xml`, etc.).
|
|
14
|
+
2. **Scope** — Review changed files (diff, selection, or named paths). Skip unrelated files.
|
|
15
|
+
3. **Context** — Read surrounding code (callers, exports, tests) before judging isolated lines.
|
|
16
|
+
4. **Apply rules** — Run the universal checklist, then project/framework rules, then language-specific notes when relevant.
|
|
17
|
+
5. **Report** — Use the output template. Every finding must include severity, location, issue, and a concrete fix.
|
|
18
|
+
6. **Summarize** — End with merge verdict and top 3 actions.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Severity levels
|
|
23
|
+
|
|
24
|
+
| Level | Meaning |
|
|
25
|
+
|-------|---------|
|
|
26
|
+
| **BLOCKER** | Must fix before merge — bugs, security, data loss, broken concurrency |
|
|
27
|
+
| **MAJOR** | Should fix — missing edge cases, weak errors, no tests for critical logic |
|
|
28
|
+
| **MINOR** | Nice to fix — naming, small refactors, duplication |
|
|
29
|
+
| **NIT** | Optional — style preference unless it violates project or linter standards |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Universal review checklist (in order)
|
|
34
|
+
|
|
35
|
+
### 1. Correctness and edge cases
|
|
36
|
+
- Logic matches requirements; no off-by-one or wrong operators
|
|
37
|
+
- Handles null/nil/None, empty collections, zero, max bounds, overflow where applicable
|
|
38
|
+
- Idempotency and duplicate operations where relevant
|
|
39
|
+
- Race conditions on shared mutable state or parallel data access
|
|
40
|
+
|
|
41
|
+
### 2. Variable declaration and naming
|
|
42
|
+
- Follow language idioms for mutability (`const`/`final`/`let`/`var` as appropriate)
|
|
43
|
+
- Names describe intent; functions are verbs; booleans use `is`/`has`/`can` where conventional
|
|
44
|
+
- Functions/classes do one thing; modules have clear responsibility
|
|
45
|
+
- No magic numbers — use named constants
|
|
46
|
+
|
|
47
|
+
### 3. Concurrency and async (when applicable)
|
|
48
|
+
- No fire-and-forget tasks without error handling
|
|
49
|
+
- Proper synchronization (locks, channels, async/await, goroutines, threads)
|
|
50
|
+
- Timeouts/cancellation on external I/O
|
|
51
|
+
- Avoid deadlocks and shared-state races
|
|
52
|
+
|
|
53
|
+
### 4. Exception and error handling
|
|
54
|
+
- Errors handled at the right layer — not swallowed in low-level helpers
|
|
55
|
+
- Meaningful messages; preserve cause/chain when rethrowing
|
|
56
|
+
- Distinguish operational errors (bad input) vs programmer errors (bugs)
|
|
57
|
+
- APIs: consistent error codes, status, or result types
|
|
58
|
+
|
|
59
|
+
### 5. Input validation and types
|
|
60
|
+
- Validate at system boundaries (HTTP, CLI, message queues, file input, env)
|
|
61
|
+
- Use the project's schema/validation library if present
|
|
62
|
+
- Strong typing where the language supports it; avoid unsafe casts without checks
|
|
63
|
+
|
|
64
|
+
### 6. Security
|
|
65
|
+
- No secrets, tokens, or PII in code or logs
|
|
66
|
+
- Parameterized queries — no string-built SQL or command injection
|
|
67
|
+
- Authorization on every protected operation (not only authentication)
|
|
68
|
+
- Safe file paths; cautious eval/exec/shell invocation
|
|
69
|
+
- User input not trusted for redirects, HTML, or system commands
|
|
70
|
+
|
|
71
|
+
### 7. Structure and maintainability
|
|
72
|
+
- Clear layering (presentation → business logic → data access)
|
|
73
|
+
- Minimal coupling; explicit dependencies over globals
|
|
74
|
+
- No dead code or commented-out blocks left behind
|
|
75
|
+
- Matches existing project patterns (naming, layout, imports)
|
|
76
|
+
|
|
77
|
+
### 8. Performance and resources
|
|
78
|
+
- N+1 queries; unbounded in-memory growth
|
|
79
|
+
- Appropriate use of streaming/batching for large data
|
|
80
|
+
- Connections, handles, and listeners closed or pooled; no leaks
|
|
81
|
+
|
|
82
|
+
### 9. Tests
|
|
83
|
+
- Critical paths and failure paths covered
|
|
84
|
+
- Tests are deterministic (mock time/network when needed)
|
|
85
|
+
- Assertions verify behavior, not implementation details
|
|
86
|
+
|
|
87
|
+
### 10. Operability
|
|
88
|
+
- Structured logging with context; appropriate levels
|
|
89
|
+
- Required config validated at startup
|
|
90
|
+
- Breaking changes documented
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Project / framework rules
|
|
95
|
+
|
|
96
|
+
Always apply when these patterns appear (tests, config, loaders, classifiers, auth, retries). Violations are usually **MAJOR**; silent wrong outcomes are **BLOCKER**.
|
|
97
|
+
|
|
98
|
+
### 1. Test Directory Naming
|
|
99
|
+
Unit tests must be in `__tests__` (plural), not `__test__` (singular). Jest `testMatch` must only include `**/__tests__/**/*.test.js` (or project equivalent). Flag and move files under `__test__`.
|
|
100
|
+
|
|
101
|
+
### 2. Remove Redundant Deduplication
|
|
102
|
+
`[...new Set(array)]` is redundant when a `break` already stops after the first match. Flag `new Set()` inside loops with early `break`.
|
|
103
|
+
|
|
104
|
+
### 3. Throw for Unknown Types Instead of Silent Skip
|
|
105
|
+
When iterating a known-type map, replace `continue` with a typed `throw` (e.g. `AuthenticationError`) that lists supported types. Silent skips hide misconfiguration.
|
|
106
|
+
|
|
107
|
+
### 4. Dynamic Import Loaders Must Return Instances
|
|
108
|
+
Loaders must be instance factories: `async () => new (await import('./Module.js')).default()`. Call site: `await loader()` — do not leak `.default` / `new` to callers.
|
|
109
|
+
|
|
110
|
+
### 5. Move Hardcoded Config Values to a Dedicated Config File
|
|
111
|
+
Header, cookie, and param names must not be inlined in logic. Extract to `*Config.js` (or equivalent). Import at module level — do not pass as args or read from runtime inputs.
|
|
112
|
+
|
|
113
|
+
### 6. Do Not Inject Config Through Function Parameters
|
|
114
|
+
If config is already imported at module level, read it inside the function. Flag parameters that only forward imported config values.
|
|
115
|
+
|
|
116
|
+
### 7. Remove Defensive Fallbacks on Guaranteed Structures
|
|
117
|
+
When structure is guaranteed, remove `|| {}`, unnecessary `?.`, and fallback chains that mask misconfiguration.
|
|
118
|
+
|
|
119
|
+
### 8. Direct Assignment Instead of Spread-Merge
|
|
120
|
+
If a value exists in only one source, assign directly (`x = actorValue`) instead of `{ ...empty, ...actorValue }`.
|
|
121
|
+
|
|
122
|
+
### 9. Validate Required Config and Throw Typed Errors
|
|
123
|
+
Explicit `if (!x) throw new AuthenticationError(...)` before use. Messages must name the missing field and config section. Errors must extend the project base class (e.g. `DataGeneratorError`).
|
|
124
|
+
|
|
125
|
+
### 10. Single Source for Config Values
|
|
126
|
+
Each value comes from exactly one place — config **or** env — never `config.x || process.env.X`.
|
|
127
|
+
|
|
128
|
+
### 11. Classification Must Read the Field That Carries the Signal
|
|
129
|
+
Classifiers/detectors must read fields that real production samples show carry the diagnostic text (often `error.message` / `error.stack`, not empty `stdout`/`stderr`). Do not trust hand-crafted fixtures alone.
|
|
130
|
+
|
|
131
|
+
### 12. One Predicate Per Concept
|
|
132
|
+
The same yes/no decision (failure/success, ignore/keep, etc.) must be one shared predicate/constant imported everywhere — not reimplemented per file.
|
|
133
|
+
|
|
134
|
+
### 13. Retry Logic Must Not Silently Discard Earlier Evidence
|
|
135
|
+
"Pick last/first failing attempt" must not drop earlier failure reasons without a deliberate, documented tradeoff.
|
|
136
|
+
|
|
137
|
+
### 14. Don't Duplicate a Guard Across Early-Exit and Loop
|
|
138
|
+
If `.some()`/`.every()` guards, then the loop re-checks the same condition, consolidate into one `.filter()` reused for both. Keep needed early-exits; avoid double-checking.
|
|
139
|
+
|
|
140
|
+
### 15. Sample Data Must Reflect the Current Code Path
|
|
141
|
+
Before treating a captured report/fixture as E2E proof, confirm it was produced by the code under review (look for expected output markers). Older samples may validate shapes only.
|
|
142
|
+
|
|
143
|
+
### 16. Dedupe Repeated Env/Config-Resolution Across Files
|
|
144
|
+
Copy-pasted env cascades (e.g. `HTTPS_PROXY` / `https_proxy` / `HTTP_PROXY` / `http_proxy`) must live in one shared helper imported everywhere — do not re-derive in each config file.
|
|
145
|
+
|
|
146
|
+
### 17. Don't Call a Helper Twice to Build One Value
|
|
147
|
+
Flag `...(getProxyConfig() ? { proxy: getProxyConfig() } : {})`. Compute once: `const proxy = getProxyConfig(); ...(proxy ? { proxy } : {})`.
|
|
148
|
+
|
|
149
|
+
### 18. Check Sibling/Fallback Paths for Drift
|
|
150
|
+
When static vs dynamic (or other parallel) entry points serve the same concern, a fix on one must be checked against the other. Flag silent divergence (e.g. only one path handles `NO_PROXY`/bypass).
|
|
151
|
+
|
|
152
|
+
### 19. Verify Module Interop Before Changing Import Style
|
|
153
|
+
Before switching `require()` ↔ `import`, check build config (e.g. Babel `@babel/plugin-transform-modules-commonjs`). Do not assume mixed styles break or are safe without verifying.
|
|
154
|
+
|
|
155
|
+
### 20. Reuse Existing fs/File Utilities
|
|
156
|
+
Prefer shared helpers like `writeFileContents` (mkdir-then-write) over inlining `mkdirSync` + `writeFileSync`.
|
|
157
|
+
|
|
158
|
+
### 21. Verify Fallback Branches Are Truly Dead Before Deleting
|
|
159
|
+
Check **all** call sites before removing an "unreachable" branch. Then drop stale defaults (`= null`) and propagate the same cleanup to wrappers.
|
|
160
|
+
|
|
161
|
+
### 22. Match Error Handling to Project Convention
|
|
162
|
+
When adding `try/catch`, use the project pattern (e.g. `Logger.error` + rethrow with contextual message) — do not let exceptions propagate bare.
|
|
163
|
+
|
|
164
|
+
### 23. Resolve Computed Values Once at the Call Site; Pass Resolved Result Inward
|
|
165
|
+
When a value (env var, domain URL, config field) is resolved at an outer scope, pass the fully resolved value into helpers — do not re-derive it inside the helper with a second fallback. Split resolution hides the real fallback logic, makes helpers implicitly depend on env vars they shouldn't know about, and makes behavior hard to test in isolation.
|
|
166
|
+
|
|
167
|
+
**Bad:**
|
|
168
|
+
```js
|
|
169
|
+
domainUrl = isPortal ? process.env.portalDomain : process.env.domain; // partial
|
|
170
|
+
const selectedDomain = new URL(domainUrl || process.env.domain); // re-derives
|
|
171
|
+
```
|
|
172
|
+
**Good:**
|
|
173
|
+
```js
|
|
174
|
+
domainUrl = isPortal ? (process.env.portalDomain || process.env.domain) : process.env.domain; // fully resolved
|
|
175
|
+
const selectedDomain = new URL(domainUrl); // just uses it
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 24. Do Not Add Conditional Branches for Use Cases With No Active Call Sites
|
|
179
|
+
Before adding a conditional path (e.g. `if (id.startsWith('portal.')) use portalDomain`), verify with `grep` that at least one real caller exercises it. If zero results, do not add the branch. Speculative branches accumulate silently, add test burden for hypothetical scenarios, and rot as the surrounding API evolves. Add when the use case actually exists.
|
|
180
|
+
|
|
181
|
+
### 25. Do Not Declare Functions `async` Without Awaited Operations
|
|
182
|
+
A function declared `async` with no `await` inside misleads readers into assuming I/O or async coordination is happening and adds an unnecessary Promise wrapper around a synchronous return. Flag `async function foo() { return array.map(...) }` with no `await` inside. Fix: remove `async` and update callers to drop `await`.
|
|
183
|
+
|
|
184
|
+
### 26. Guard Null/Undefined Inputs at Array Utility Entry Points
|
|
185
|
+
Utility functions that call `.map()`, `.filter()`, or `.reduce()` on a parameter must guard against `null`/`undefined` at the top — otherwise callers get a cryptic `TypeError: Cannot read properties of null (reading 'map')` with no context.
|
|
186
|
+
|
|
187
|
+
**Fix:**
|
|
188
|
+
```js
|
|
189
|
+
if (!generators?.length) return [];
|
|
190
|
+
return generators.map(...);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### 27. Every Throw Site in a Subsystem Must Use the Subsystem's Typed Error
|
|
194
|
+
When a module defines a typed error hierarchy (e.g. `AuthenticationError extends DataGeneratorError`), every `throw` inside that subsystem must use the typed error — not the base `Error`. The outer catch block uses `instanceof` to route handling; a bare `throw new Error(...)` breaks that routing silently. Flag any `throw new Error(...)` inside a file that imports and uses a typed error class.
|
|
195
|
+
|
|
196
|
+
### 29. No Trailing Commas on Last Object/Array Property (comma-dangle)
|
|
197
|
+
Do not place a trailing comma after the last property in an object literal or the last element in an array literal when the project ESLint rule is `comma-dangle: never`. Flag any `,` immediately before a closing `}` or `]`.
|
|
198
|
+
|
|
199
|
+
**Bad:**
|
|
200
|
+
```js
|
|
201
|
+
const obj = {
|
|
202
|
+
type: 'dynamic',
|
|
203
|
+
name: 'gen1', // ← trailing comma
|
|
204
|
+
};
|
|
205
|
+
```
|
|
206
|
+
**Good:**
|
|
207
|
+
```js
|
|
208
|
+
const obj = {
|
|
209
|
+
type: 'dynamic',
|
|
210
|
+
name: 'gen1'
|
|
211
|
+
};
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### 28. In Format Translation, Only Translate Fields Explicitly Confirmed to Differ
|
|
215
|
+
When writing a v1→v2 (or any format) translator, start from the assumption that all fields pass through unchanged. Only rename or remove a field when you have explicit confirmation the target format uses a different name or drops the field entirely. Before removing or renaming a field, check the target API's response or logs to confirm it doesn't consume the original field name. Stripping a field shared by both formats silently breaks the downstream system with no error at the translation layer.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Language-specific notes
|
|
220
|
+
|
|
221
|
+
Apply only the section(s) matching the code under review.
|
|
222
|
+
|
|
223
|
+
### JavaScript / TypeScript / Node.js
|
|
224
|
+
- Prefer `const`; use `let` when reassigned; avoid `var`
|
|
225
|
+
- No floating promises — await or attach `.catch()`
|
|
226
|
+
- `Promise.all` vs `Promise.allSettled` used correctly
|
|
227
|
+
- TypeScript: narrow types at boundaries; avoid unnecessary `any`
|
|
228
|
+
- Express/Fastify: central error middleware; async route errors reach it
|
|
229
|
+
|
|
230
|
+
### Python
|
|
231
|
+
- Prefer explicit exceptions over bare `except:` or silent `pass`
|
|
232
|
+
- Use context managers (`with`) for files, locks, connections
|
|
233
|
+
- Type hints on public APIs when the project uses them
|
|
234
|
+
- Avoid mutable default arguments (`def f(x=[])`)
|
|
235
|
+
- Async: don't mix blocking I/O inside `async def` without `asyncio.to_thread`
|
|
236
|
+
|
|
237
|
+
### Java / Kotlin
|
|
238
|
+
- Resources in try-with-resources or equivalent
|
|
239
|
+
- Null safety: Optional, `@Nullable`/`@NonNull`, or Kotlin null types used consistently
|
|
240
|
+
- Checked vs unchecked exceptions match project style
|
|
241
|
+
- Thread safety on shared mutable fields
|
|
242
|
+
- Spring: validate `@RequestBody`; secure endpoints with method-level auth
|
|
243
|
+
|
|
244
|
+
### Go
|
|
245
|
+
- Every error returned checked — no `_` discard without justification
|
|
246
|
+
- Context passed and honored for cancellation/timeouts
|
|
247
|
+
- Goroutine leaks: ensure exit paths; use `errgroup` or wait groups
|
|
248
|
+
- Defer order and panic/recover only at boundaries
|
|
249
|
+
- Exported names and package layout follow Go conventions
|
|
250
|
+
|
|
251
|
+
### C# / .NET
|
|
252
|
+
- `async`/`await` all the way; no `.Result` / `.Wait()` on async code
|
|
253
|
+
- `IDisposable` / `using` for unmanaged resources
|
|
254
|
+
- Nullable reference types respected when enabled
|
|
255
|
+
- LINQ queries not causing unintended multiple enumeration or N+1
|
|
256
|
+
|
|
257
|
+
### Rust
|
|
258
|
+
- Minimize `unwrap()`/`expect()` in production paths — propagate with `?`
|
|
259
|
+
- Lock poisoning and Send/Sync bounds for concurrent code
|
|
260
|
+
- Unsafe blocks justified and documented
|
|
261
|
+
- Error types use `thiserror`/`anyhow` or project standard
|
|
262
|
+
|
|
263
|
+
### Ruby
|
|
264
|
+
- No SQL string interpolation — use bound parameters
|
|
265
|
+
- Blocks and ensure/finally for cleanup
|
|
266
|
+
- Thread safety for class variables and caches
|
|
267
|
+
|
|
268
|
+
### PHP
|
|
269
|
+
- Prepared statements for DB; escape output for XSS context
|
|
270
|
+
- Strict types (`declare(strict_types=1)`) when project uses them
|
|
271
|
+
- Avoid `@` error suppression
|
|
272
|
+
|
|
273
|
+
### SQL
|
|
274
|
+
- Migrations reversible or documented when not
|
|
275
|
+
- Indexes for new query patterns; avoid `SELECT *`
|
|
276
|
+
- No destructive changes without backup/rollback plan
|
|
277
|
+
|
|
278
|
+
### HTML / CSS / Frontend
|
|
279
|
+
- Accessible labels, focus, and semantic markup
|
|
280
|
+
- XSS: no unsanitized user HTML
|
|
281
|
+
- State updates avoid stale closures and race conditions
|
|
282
|
+
|
|
283
|
+
### Shell / Bash
|
|
284
|
+
- `set -euo pipefail` when script expects it
|
|
285
|
+
- Quote variables; no unvalidated input in commands
|
|
286
|
+
- Idempotent scripts where run repeatedly
|
|
287
|
+
|
|
288
|
+
When the change is polyglot (e.g. JS + SQL + YAML), review each file with the matching section.
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## Naming reference (all languages)
|
|
293
|
+
|
|
294
|
+
| Kind | Guideline | Examples |
|
|
295
|
+
|------|-----------|----------|
|
|
296
|
+
| Variables | Noun or noun phrase | `orderTotal`, `userCount` |
|
|
297
|
+
| Functions | Verb + object | `getUserById`, `validateInput` |
|
|
298
|
+
| Booleans | `is`, `has`, `can`, `should` | `isValid`, `hasPermission` |
|
|
299
|
+
| Constants | Project convention | `MAX_RETRIES`, `DefaultTimeout` |
|
|
300
|
+
| Types/Classes | Domain noun | `OrderService`, `PaymentGateway` |
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## Edge cases to probe
|
|
305
|
+
|
|
306
|
+
- Missing, null, or empty inputs
|
|
307
|
+
- Single element vs many; first/last/boundary indices
|
|
308
|
+
- Zero and negative numbers where only positive expected
|
|
309
|
+
- Duplicate or concurrent requests
|
|
310
|
+
- External dependency timeout, partial failure, retry storms
|
|
311
|
+
- Unicode, whitespace-only strings, very long strings
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Test expectations by change type
|
|
316
|
+
|
|
317
|
+
| Change | Minimum expectation |
|
|
318
|
+
|--------|---------------------|
|
|
319
|
+
| Bug fix | Regression test reproducing the bug |
|
|
320
|
+
| New API/endpoint | Success + validation error + auth failure if protected |
|
|
321
|
+
| Pure utility | Happy path + 1–2 edge cases |
|
|
322
|
+
| Refactor only | Existing tests pass; flag coverage gaps |
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## Merge verdict guide
|
|
327
|
+
|
|
328
|
+
| Verdict | When |
|
|
329
|
+
|---------|------|
|
|
330
|
+
| **APPROVE** | No BLOCKER or MAJOR; MINOR/NIT only |
|
|
331
|
+
| **APPROVE WITH COMMENTS** | MAJOR items tracked as follow-ups with owner |
|
|
332
|
+
| **REQUEST CHANGES** | Any BLOCKER, or MAJOR without agreed follow-up |
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Output template
|
|
337
|
+
|
|
338
|
+
Use this format for every review:
|
|
339
|
+
|
|
340
|
+
```markdown
|
|
341
|
+
# Code Review: [brief title]
|
|
342
|
+
|
|
343
|
+
**Scope:** [files or diff reviewed]
|
|
344
|
+
**Language(s):** [detected languages]
|
|
345
|
+
**Verdict:** APPROVE | APPROVE WITH COMMENTS | REQUEST CHANGES
|
|
346
|
+
|
|
347
|
+
## Summary
|
|
348
|
+
[2–4 sentences: overall quality and main risks]
|
|
349
|
+
|
|
350
|
+
## Findings
|
|
351
|
+
|
|
352
|
+
### BLOCKER
|
|
353
|
+
- **[file:line]** — [issue]. **Fix:** [concrete change]
|
|
354
|
+
|
|
355
|
+
### MAJOR
|
|
356
|
+
- **[file:line]** — [issue]. **Fix:** [concrete change]
|
|
357
|
+
|
|
358
|
+
### MINOR / NIT
|
|
359
|
+
- **[file:line]** — [issue]. **Fix:** [concrete change]
|
|
360
|
+
|
|
361
|
+
## Positive notes
|
|
362
|
+
- [What was done well — important for mentees]
|
|
363
|
+
|
|
364
|
+
## Recommended next steps
|
|
365
|
+
1. ...
|
|
366
|
+
2. ...
|
|
367
|
+
3. ...
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Rules for feedback
|
|
373
|
+
|
|
374
|
+
- Be specific: cite `file:line` and show a short before/after when helpful
|
|
375
|
+
- Prefer project conventions and language idioms over personal taste
|
|
376
|
+
- Do not nitpick formatting already enforced by linters/formatters (ESLint, Prettier, Ruff, gofmt, etc.)
|
|
377
|
+
- For mentees: explain **why** for BLOCKER and MAJOR
|
|
378
|
+
- If the diff is too large, ask to split the PR or review file-by-file
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## Quick prompts for VS Code Copilot Chat
|
|
383
|
+
|
|
384
|
+
**Review staged changes:**
|
|
385
|
+
```
|
|
386
|
+
Review my staged/git changes using the Code Review Agent rules in this repo.
|
|
387
|
+
Output BLOCKER, MAJOR, MINOR, NIT with file:line and fixes. Give a verdict.
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
**Review selection:**
|
|
391
|
+
```
|
|
392
|
+
Review the selected code as the Code Review Agent. Detect the language and apply the full checklist.
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**Mentee review:**
|
|
396
|
+
```
|
|
397
|
+
Review this code for a junior developer. Use Code Review Agent format.
|
|
398
|
+
Explain why for each BLOCKER and MAJOR finding.
|
|
399
|
+
```
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Code Review Instructions
|
|
2
|
+
|
|
3
|
+
Guidelines for reviewing code changes in this framework. Use these as input when running an automated review agent.
|
|
4
|
+
|
|
5
|
+
Source also mirrored in the Cursor `code-review` skill (`PROJECT-RULES.md`).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Test Directory Naming
|
|
10
|
+
|
|
11
|
+
Unit tests must be placed in `__tests__` (plural), not `__test__` (singular).
|
|
12
|
+
|
|
13
|
+
- Jest `testMatch` config must only include `**/__tests__/**/*.test.js` (or the project's equivalent)
|
|
14
|
+
- Flag test files under `__test__` and require move to `__tests__`
|
|
15
|
+
|
|
16
|
+
## 2. Remove Redundant Deduplication
|
|
17
|
+
|
|
18
|
+
`[...new Set(array)]` to deduplicate is redundant when a `break` already stops iteration after the first match.
|
|
19
|
+
|
|
20
|
+
- Flag `new Set()` usage inside loops that have an early `break`
|
|
21
|
+
- Remove unnecessary Set construction
|
|
22
|
+
|
|
23
|
+
## 3. Throw for Unknown Types Instead of Silent Skip
|
|
24
|
+
|
|
25
|
+
When iterating over a known-type map, replace `continue` with a descriptive `throw` for unrecognised values.
|
|
26
|
+
|
|
27
|
+
- Silent skips hide misconfiguration from the caller
|
|
28
|
+
- Thrown errors must be typed (e.g. `AuthenticationError`) with a message listing the supported types
|
|
29
|
+
|
|
30
|
+
## 4. Dynamic Import Loaders Must Return Instances
|
|
31
|
+
|
|
32
|
+
When a loader map uses `() => import('./Module.js')`, the call site is forced to destructure `.default` and call `new`. This leaks module internals into the call site.
|
|
33
|
+
|
|
34
|
+
- Each loader should be an instance factory: `async () => new (await import('./Module.js')).default()`
|
|
35
|
+
- Call site should simply do `await loader()` to get a ready-to-use instance
|
|
36
|
+
|
|
37
|
+
## 5. Move Hardcoded Config Values to a Dedicated Config File
|
|
38
|
+
|
|
39
|
+
Constants such as header names, cookie names, and param names must not be inlined in logic files.
|
|
40
|
+
|
|
41
|
+
- Extract them to a dedicated `*Config.js` (or project-equivalent) file
|
|
42
|
+
- Import the config file directly at the module level — do not pass values as function arguments or read them from runtime inputs
|
|
43
|
+
|
|
44
|
+
## 6. Do Not Inject Config Through Function Parameters
|
|
45
|
+
|
|
46
|
+
If a config file is already imported at the module level, read from it directly inside the function.
|
|
47
|
+
|
|
48
|
+
- Flag any function that receives config values as parameters when those values are available from an imported module
|
|
49
|
+
- Remove the parameter and replace with a direct reference to the imported config
|
|
50
|
+
|
|
51
|
+
## 7. Remove Defensive Fallbacks on Guaranteed Structures
|
|
52
|
+
|
|
53
|
+
When configuration is guaranteed to have a specific structure, defensive fallbacks must be removed.
|
|
54
|
+
|
|
55
|
+
- Flag `|| {}`, optional chaining `?.`, and fallback chains on paths that are always present
|
|
56
|
+
- These mask real misconfiguration errors and make bugs harder to trace
|
|
57
|
+
|
|
58
|
+
## 8. Direct Assignment Instead of Spread-Merge
|
|
59
|
+
|
|
60
|
+
If a value only exists in one source, assign it directly rather than merging.
|
|
61
|
+
|
|
62
|
+
- Flag `{ ...apiPayload.account.x, ...actorValue }` when the left side is always empty at that point
|
|
63
|
+
- Replace with direct assignment: `apiPayload.account.x = actorValue`
|
|
64
|
+
|
|
65
|
+
## 9. Validate Required Config and Throw Typed Errors
|
|
66
|
+
|
|
67
|
+
Each authenticator (or similar component) must explicitly validate required config fields before use.
|
|
68
|
+
|
|
69
|
+
- Use explicit `if (!x) throw new AuthenticationError(...)` checks — a `try/catch` wrapper is not required
|
|
70
|
+
- Error messages must clearly identify which field is missing and in which config section
|
|
71
|
+
- Thrown errors must extend the project's base error class (e.g. `DataGeneratorError`) so they are handled correctly up the call chain
|
|
72
|
+
|
|
73
|
+
## 10. Single Source for Config Values
|
|
74
|
+
|
|
75
|
+
Each config value must come from exactly one place — either actor/app config or an environment variable, not one with a fallback to the other.
|
|
76
|
+
|
|
77
|
+
- Flag patterns like `jwtConf.token_url || process.env.DG_JWT_TOKEN_URL`
|
|
78
|
+
- Mixed sourcing makes behaviour unpredictable and harder to debug
|
|
79
|
+
|
|
80
|
+
## 11. Classification/Detection Code Must Read the Field That Actually Carries the Signal
|
|
81
|
+
|
|
82
|
+
When code claims to classify or detect something from an input (logs, stdout/stderr, error objects, API payloads), verify — against real production samples, not just hand-written unit-test fixtures — that the fields actually being read carry the diagnostic signal.
|
|
83
|
+
|
|
84
|
+
- Flag classifiers/matchers whose only inputs are fields that real samples show are empty or generic, while the real signal lives in another field (e.g. `error.message` / `error.stack`) that is never read
|
|
85
|
+
- Fixtures that hand-craft convenient input can mask this — confirm against a real captured run, not just the test suite
|
|
86
|
+
|
|
87
|
+
## 12. One Predicate Per Concept, Not Reimplemented Per Call Site
|
|
88
|
+
|
|
89
|
+
When the same yes/no decision (e.g. "is this result a failure") is computed in more than one file, it must be expressed via a single shared predicate/constant that every call site imports — not reimplemented independently in each place, even if the reimplementations currently agree.
|
|
90
|
+
|
|
91
|
+
- Flag any boolean classification (failure/success, ignore/keep, valid/invalid) that appears as independently-written logic in more than one file
|
|
92
|
+
|
|
93
|
+
## 13. Retry/Multi-Attempt Logic Must Not Silently Discard Earlier Evidence
|
|
94
|
+
|
|
95
|
+
When a function picks one representative item from a set of retry attempts, check whether discarding the others loses information that changes the reported outcome.
|
|
96
|
+
|
|
97
|
+
- Flag "pick last/first from a filtered list" patterns in retry-aware code
|
|
98
|
+
- Confirm whether losing the other candidates is a deliberate, documented tradeoff
|
|
99
|
+
|
|
100
|
+
## 14. Don't Duplicate a Guard Condition Across an Early-Exit and a Loop Body
|
|
101
|
+
|
|
102
|
+
If a value is checked once via `.some()`/`.every()` as an early-exit guard, and the same per-item condition is re-checked again inside the following loop, consolidate into a single `.filter()` (or equivalent) computed once and reused for both the emptiness check and the iteration.
|
|
103
|
+
|
|
104
|
+
- Do not remove a needed early-exit guard — just avoid checking the same condition twice
|
|
105
|
+
|
|
106
|
+
## 15. Validate Reference/Sample Data Reflects the Current Code Path
|
|
107
|
+
|
|
108
|
+
Before treating a sample dataset (captured report, log dump, or fixture) as proof a feature works, confirm it was produced by the code path under review, not an older build.
|
|
109
|
+
|
|
110
|
+
- Check for the feature's expected output markers/side effects in the sample before relying on it as end-to-end validation
|
|
111
|
+
- Older samples may still validate input *shapes*, but not feature output
|
|
112
|
+
|
|
113
|
+
## 16. Dedupe Repeated Env/Config-Resolution Logic Across Files
|
|
114
|
+
|
|
115
|
+
Env/config resolution that appears in multiple files (e.g. proxy lookup of `HTTPS_PROXY` / `https_proxy` / `HTTP_PROXY` / `http_proxy`) must be extracted into a single shared helper and imported everywhere.
|
|
116
|
+
|
|
117
|
+
- Flag copy-pasted env-var cascades or identical resolution blocks across config files
|
|
118
|
+
- Do not re-derive the same value in each file
|
|
119
|
+
|
|
120
|
+
## 17. Don't Call a Helper Twice to Build One Value
|
|
121
|
+
|
|
122
|
+
When spreading a conditional helper result into an object, compute it once into a local variable, then reference that variable.
|
|
123
|
+
|
|
124
|
+
- Flag: `...(getProxyConfig() ? { proxy: getProxyConfig() } : {})`
|
|
125
|
+
- Prefer: `const proxy = getProxyConfig(); ...(proxy ? { proxy } : {})`
|
|
126
|
+
|
|
127
|
+
## 18. Check Sibling/Fallback Code Paths for Drift
|
|
128
|
+
|
|
129
|
+
When parallel entry points exist for the same concern (e.g. static root config vs dynamically generated config, selected by a runtime check), a fix applied to one must be checked against the other.
|
|
130
|
+
|
|
131
|
+
- They can silently diverge (e.g. one path handles `NO_PROXY`/bypass, the other does not)
|
|
132
|
+
- Flag incomplete parity when reviewing fixes that touch only one of the sibling paths
|
|
133
|
+
|
|
134
|
+
## 19. Verify Module Interop Before Changing Import Style
|
|
135
|
+
|
|
136
|
+
Before switching `require()` to `import` (or vice versa), check the build config (e.g. Babel `@babel/plugin-transform-modules-commonjs`) to confirm mixed `require`/`import` in the same file is actually safe.
|
|
137
|
+
|
|
138
|
+
- Do not assume mixed styles will break — or that they are fine — without verifying the toolchain
|
|
139
|
+
|
|
140
|
+
## 20. Reuse Existing fs/File Utilities Instead of Inlining Raw fs Calls
|
|
141
|
+
|
|
142
|
+
Prefer shared helpers (e.g. `writeFileContents` that already does mkdir-then-write) over manual `mkdirSync` + `writeFileSync` in new call sites.
|
|
143
|
+
|
|
144
|
+
- Flag duplicated low-level fs sequences when a project utility already encapsulates them
|
|
145
|
+
|
|
146
|
+
## 21. Verify a Fallback Branch Is Truly Dead Before Deleting It
|
|
147
|
+
|
|
148
|
+
Before removing an "unreachable" branch (e.g. a fetch fallback when a `page` param is always passed), check **all** call sites of the function.
|
|
149
|
+
|
|
150
|
+
- Only then simplify the signature (drop stale defaults like `= null`)
|
|
151
|
+
- Propagate that simplification to any wrapper functions that also carried the same stale default
|
|
152
|
+
|
|
153
|
+
## 22. Match Error Handling to Existing Project Convention
|
|
154
|
+
|
|
155
|
+
When replacing a branch with `try/catch`, use the established logging pattern (e.g. `Logger.error` + rethrow with a contextual message) rather than letting exceptions propagate bare.
|
|
156
|
+
|
|
157
|
+
- Flag bare rethrows or silent catches that break project error-handling conventions
|
package/jest.config.js
CHANGED
|
@@ -5,8 +5,18 @@ const appPath = process.cwd();
|
|
|
5
5
|
const appGlobals = path.resolve(appPath, '__testUtils__', 'globals.js');
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
|
+
reporters: [
|
|
9
|
+
"default",
|
|
10
|
+
[
|
|
11
|
+
"jest-html-reporter",
|
|
12
|
+
{
|
|
13
|
+
outputPath: "unit_reports/unit-report.html",
|
|
14
|
+
pageTitle: "Unit Report"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
],
|
|
8
18
|
rootDir: process.cwd(),
|
|
9
|
-
testEnvironment: '
|
|
19
|
+
testEnvironment: 'node',
|
|
10
20
|
|
|
11
21
|
setupFilesAfterEnv: [
|
|
12
22
|
existsSync(appGlobals) && appGlobals,
|
|
@@ -21,13 +31,21 @@ module.exports = {
|
|
|
21
31
|
'jest',
|
|
22
32
|
'preprocessor',
|
|
23
33
|
'jsPreprocessor.js'
|
|
24
|
-
)
|
|
34
|
+
),
|
|
35
|
+
'^.+\\.jsx?$': 'babel-jest'
|
|
25
36
|
},
|
|
37
|
+
|
|
38
|
+
testMatch: ['**/__tests__/**/*.test.js'],
|
|
26
39
|
|
|
27
40
|
modulePathIgnorePatterns: ['/build/'],
|
|
28
41
|
|
|
29
42
|
transformIgnorePatterns: [
|
|
30
|
-
'/node_modules/
|
|
43
|
+
'/node_modules/',
|
|
44
|
+
'/src/setup-folder-structure/samples/'
|
|
45
|
+
],
|
|
46
|
+
|
|
47
|
+
coveragePathIgnorePatterns:[
|
|
48
|
+
'/src/setup-folder-structure/samples/'
|
|
31
49
|
],
|
|
32
50
|
|
|
33
51
|
testPathIgnorePatterns: [
|
|
@@ -48,14 +66,14 @@ module.exports = {
|
|
|
48
66
|
collectCoverageFrom: ['src/**/*.js'],
|
|
49
67
|
coverageDirectory: './build/cov',
|
|
50
68
|
coverageReporters: ['lcov', 'json', 'html', 'json-summary', 'text'],
|
|
51
|
-
coverageThreshold: {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
69
|
+
// coverageThreshold: {
|
|
70
|
+
// global: {
|
|
71
|
+
// branches: 100,
|
|
72
|
+
// functions: 100,
|
|
73
|
+
// lines: 100,
|
|
74
|
+
// statements: 100
|
|
75
|
+
// }
|
|
76
|
+
// },
|
|
59
77
|
globals: {
|
|
60
78
|
__DEVELOPMENT__: true,
|
|
61
79
|
__DOCS__: false,
|