passsy / test-real-production-coder3
Test the Real Production Code
PublicImport and exercise the real code from lib/ in tests and never copy or reimplement production logic in a test file, because a test of a copy passes while production is broken.
detector.tsisolate · reads files, writes none · no network · 100 ms · 32 MBEdit
import { mentioned, onPrompt } from "@wellactually/sdk/v3";
import { isDartProject } from "dart-kit";
/**
* Words only. A copied implementation and a legitimate test helper look
* identical to a single-file heuristic (a plain class in a test file is
* usually an in-memory store, not a mirror of lib/), so a code trigger here
* fired on ordinary scaffolding far more often than on the sin. Catching the
* copy needs the diff and lib/ side by side, which is review territory.
*/
onPrompt({
*detect(event) {
if (isDartProject(event)) {
yield* mentioned(event, ["reference implementation", "reimplement", "reimplementation"]);
}
},
});
fixtures/dart_app/pubspec.yamlEdit
namedemo
environment
sdk^3.5.0
package.jsonEdit
{
"name": "test-real-production-code",
"private": true,
"dependencies": {
"dart-kit": "*"
}
}