Repository navigation
docs: Add unit testing guide - #1606
Merged
Merged
Conversation
Adapt Apify's internal unit testing guide to this repo: tests/AGENTS.md with the read-before-writing gate and the test layer rule, and tests/UNIT_TESTING_GUIDE.md with the scope, test double, assertion, coverage and readability rules. The root test naming rule now names describe blocks after behaviors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…MENT docs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jirispilka
marked this pull request as ready for review
October 16, 2026 07:44
RobertCrupa
approved these changes
Oct 16, 2026
RobertCrupa
left a comment
Contributor
There was a problem hiding this comment.
Two of the new guidelines clash with existing tests:
- The new naming rule - many tests use
describe('fn()') - The "no hidden setup in beforeEach" rule - many test files use
beforeEach
Is there be follow up Issue to fix these?
Collaborator
Author
Yes, follow up is the linked issue, the text there is a bit burried: |
MQ37
reviewed
Oct 19, 2026
MQ37
left a comment
Contributor
There was a problem hiding this comment.
- examples in
UNIT_TESTING_GUIDE.mdcome from the platform repo and don't exist here (makeUser,DEFAULT_ACCOUNTS,USER_KEYS,mockStep,api.slack.com), so an agent that greps for them finds nothing. the "One reviewed suite ..." stories are about 2 KB of the 10 KB every agent has to read in full on each unit test edit. I think one rule + one snippet with local names is enough,mockTask(overrides)is already a factory with overrides - the read-in-full gate is stated 5 times (
tests/AGENTS.md:7and:11,AGENTS.md:46,CONTRIBUTING.md:382,DEVELOPMENT.md:148). rootAGENTS.mdis always loaded so one sentence there + one callout intests/AGENTS.mdshould do, CONTRIBUTING and DEVELOPMENT can just keep the link tests/AGENTS.md:12and:16are the same rule,:18points to the guide which points back here, and the layer list in:24-28repeats the table in DEVELOPMENT.md. merge:12/:16, drop:18, link the table instead of repeating it
Reverts 69e2af3 and 1076ba8. They softened every rule that caps test count (wiring pair, same-path, positive/negative) and turned the checklist into cover/keep only, against the guide's own thesis. Keeps the two additions worth having: the mockApifyClient cast note and the merged comment bullet. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Collaborator
Author
|
Addressed in 1918754: anecdotes and platform-only names replaced with local ones ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a port of convention from apify-core as written by Pepa.
The number of unit-tests is exploding and this could help to have it under control 🤞🏻
Unit tests here have no written rules beyond naming and "follow existing patterns". Agent-written suites drift toward volume: tests that re-prove helpers with their own suites,
it.eachtables over inputs that take one code path, shared mutable mocks, and whole-sentence text pins, while error and fallback branches stay untested. Apify's platform repo solved this with a unit testing guide that agents must read before writing a test; this PR adapts it.Follow-up: #1607 brings the existing unit and integration tests in line with the guide.
Drafted with Claude Code (AI-assisted).
🤖 Generated with Claude Code