docs: document that unit tests require TEST_SNYK_TOKEN - #7062
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
5c5ee98 to
458b5a2
Compare
458b5a2 to
e14c521
Compare
| # TypeScript unit tests | ||
| npm run test:unit | ||
| # TypeScript unit tests (some suites validate credentials, so a token is required) | ||
| TEST_SNYK_TOKEN=<token> npm run test:unit |
There was a problem hiding this comment.
The docs do not instruct the agent that they need to build the CLI before they can run the tests. My agent didn't notice as it built the CLI first anyway, but would it be worth adding this requirement as well?
This comment has been minimized.
This comment has been minimized.
e14c521 to
9115b35
Compare
This comment has been minimized.
This comment has been minimized.
9115b35 to
776f515
Compare
Co-authored-by: Ben Durrans <Benjamin.Durrans@snyk.io>
776f515 to
4ef326e
Compare
This comment has been minimized.
This comment has been minimized.
PR Reviewer Guide 🔍
|
There was a problem hiding this comment.
Verification results
Ran the verification skill against this diff. Changed files: AGENTS.md, CONTRIBUTING.md — both plain Markdown (mode 100644), no code changes → classified as a DOCS-class change, so only the adversarial reviewer lens ran.
Verdict: PASS — no findings.
The reviewer independently verified every factual claim in the new prose against the actual source it describes:
test/setup.jsdoes stripSNYK_TOKEN/SNYK_API_KEYand writeTEST_SNYK_TOKENinto the CLI user config, matching the new text in both files.validateCredentials/apiTokenExists()does throwMissingApiTokenErrorwhen no token is configured, and is called unmocked in the command entry points the PR calls out.- The referenced suites and the pre-existing
docs.snyk.ioauthentication link both check out. - No contradiction with the surrounding "unit tests shouldn't hit real services" guidance, since the check is local-only.
No Critical / Should Fix / Suggestion items were raised.
Auto-approval: this automation only auto-approves PRs that are pure dependency bumps (e.g. a go.mod/lockfile-only version change). Since this PR modifies documentation content rather than bumping a dependency, it is not being auto-approved, even though verification passed — it's left here for a human reviewer to approve.
Sent by Cursor Automation: Automatic PR verification


Pull Request Submission Checklist
What does this PR do?
Documents that
npm run test:unitrequiresTEST_SNYK_TOKEN.Without it, four suites fail with
MissingApiTokenError, because they drive command entry points that callvalidateCredentialsbefore doing anything else:test/jest/unit/lib/commands/fix/fix.spec.tstest/jest/unit/python/snyk-test-pyproject.spec.tstest/jest/unit/pnpm/snyk-test-pnpm-project.spec.tstest/jest/unit/snyk-code/snyk-code-test-report.spec.tsThis wasn't written down anywhere.
CONTRIBUTING.mdmentionsTEST_SNYK_TOKENonly under acceptance tests, andAGENTS.mdshowed a barenpm run test:unit.The part worth documenting explicitly is that reaching for
SNYK_TOKEN— the obvious variable, and the one the CLI itself uses — has no effect.test/setup.jsdeletesSNYK_TOKENandSNYK_API_KEY, then writesTEST_SNYK_TOKENinto the CLI user config. That's sensible (tests run against a known configuration rather than whatever the developer is authenticated as), but from the outside it looks like the token is being ignored and the tests are simply broken.This came out of an agent reporting these suites as failures during environment setup, having concluded from the error that
SNYK_TOKENwas needed. It isn't, and setting it changes nothing.No behaviour is changed here — this only documents what already happens. Whether these suites should need a token is a separate question:
CONTRIBUTING.mdstates unit tests "should not test services outside the code itself", so arguably they belong at the acceptance layer. Happy to raise that separately if the team agrees.Where should the reviewer start?
CONTRIBUTING.md-> "Unit tests". TheAGENTS.mdchange mirrors it.How should this be manually tested?
What's the product update that needs to be communicated to CLI users?
None — contributor documentation only.
Risk assessment: Low
Documentation only.
Made with Cursor