{"slug": "the-test-that-passed-without-testing-the-requirement", "title": "The Test That Passed Without Testing the Requirement", "summary": "A developer rebuilding a personal site on Astro with GitHub Copilot CLI discovered that one of their automated checks, part of a verifier reporting over 2,000 passing assertions, validated hreflang links rather than the visible language switcher visitors click. An AI-assisted code audit showed the test could pass even when the switcher's href pointed to the German homepage instead of the translated article; the developer fixed the verifier to compare the switcher's href against an expected path defined outside the generated HTML.", "body_md": "*An AI-assisted code audit found that my language-switcher test could pass without checking the destination visitors would actually use.*\n\nWhile modernizing my personal website, [yonka.dev](https://yonka.dev), I used [GitHub Copilot CLI](https://docs.github.com/en/copilot/concepts/copilot-surfaces/copilot-cli) to assist with implementation, code review, and automated verification. I replaced an ASP.NET-based site with [Astro](https://astro.build/), which generates static HTML during a production build.\n\nThis was a personal website, not a large production system. I chose it as a manageable place to experiment with AI-assisted engineering. I had taken a course on GitHub Copilot CLI, which helped me learn the tool, but it didn't give me a complete workflow for deciding what to delegate, what to review, or what evidence to trust. Those questions became concrete once I started building.\n\nI didn't begin with an established workflow. I let Copilot analyze the project and propose approaches, then examined the results and learned from the gaps I found. Even on a small website, this gave me problems to work through that a course alone hadn't prepared me for.\n\nOne requirement was simple: the site supports English and German, and switching languages should open the equivalent page when a translation exists. My automated verification reports eventually showed more than 2,000 passing assertions. Then a separate AI-assisted code audit found that one check could pass without confirming where the visible language switcher actually led.\n\nThe audit did not uncover a broken link on the live site. It uncovered a test that wasn't checking the requirement I thought it was.\n\nA successful Astro build means the site was generated, not that every page behaves as intended. To examine the output, I had used Copilot to help create `scripts/verify-dist.mjs`, a JavaScript verifier that reads the generated HTML in `dist/`. In other words, the checks examined the built pages, not merely the source templates. The problem wasn't a discrepancy introduced by Astro during the build; it was what the verifier chose to inspect.\n\nThe existing check examined links with a `hreflang` attribute. These links describe alternative language versions of a page for search engines. That's useful metadata to verify, but it is separate from the language switcher visitors click.\n\nThe visible switcher was identified by the CSS class `.language-link`. Its `lang` attribute described the language of the link text, while its `href` determined the destination. To test the navigation requirement, the verifier needed to compare that `href` against the expected destination for the current page. It didn't.\n\nConsider a visitor reading an English article with a German translation. These two links look nearly identical:\n\n**Expected destination:**\n\n```\n<a class=\"language-link\"\n   lang=\"de\"\n   href=\"https://dev.to/de/writing/example-article/\">\n  Deutsch\n</a>\n```\n\n**Wrong destination:**\n\n```\n<a class=\"language-link\"\n   lang=\"de\"\n   href=\"https://dev.to/de/\">\n  Deutsch\n</a>\n```\n\nBoth URLs can point to existing pages. But only the first takes the reader to the translated article; the second sends them to the German homepage. Because the original check inspected different language-related links, it could pass in either case. Checking that a link exists, or even that its destination exists, would not establish that it leads to the *right* page.\n\nAfter examining the finding, I used Copilot CLI to update the verifier. The corrected check reads the visible switcher's `href` and compares it with an expected path defined separately from the generated HTML:\n\n``` js\nconst destination = attr(switcher ?? \"\", \"href\");\n\nif (destination !== expectedPath)\n  fail(\n    page,\n    `language switcher points to ${destination ?? \"nothing\"}, expected ${expectedPath}`\n  );\n```\n\n*Simplified excerpt from the updated verification script.*\n\nThe full correction also checks the switcher's `lang` attribute and handles articles without a German translation. For those pages, the site has an intentional fallback destination. The expected result therefore depends on the route; it cannot be derived simply by assuming every article has a translated counterpart.\n\nDefining those expectations independently is important. If a test gets its expected destination from the same generated link it is validating, it can confirm that the implementation agrees with itself without confirming that it meets the requirement.\n\nThe revised verification passed against the normal build. But a passing result alone was exactly what had misled me before. I wanted evidence that the new assertion would reject the specific error the old one had missed.\n\nI asked the agent to run a controlled negative test: take a correctly generated article switcher and replace its destination with the German homepage in a temporary, in-memory copy of the HTML. No source file or deployed page was changed.\n\nWhen the agent ran the corrected logic against that modified HTML, **the assertion failed as expected**. It rejected the homepage destination even though the URL itself was valid.\n\n![Diagram showing a correct language-switcher destination, an intentionally incorrect destination, and the verification rejecting the incorrect one.] \n\n*The controlled incorrect destination was rejected by the updated check.*\n\nThis confirmed that the updated check could detect the specific error we introduced. It didn't establish that every possible language-switching scenario was covered.\n\nMore than 2,000 passing assertions may sound excessive for a personal website, but many were repeated checks across generated pages. I don't think the count itself tells me much about the quality of verification anymore. In this case, one missing comparison mattered more than all the passing results around it.\n\nI had relied heavily on AI to write and run the checks. A separate AI-assisted audit caught the omission, and the agent also ran the negative test that confirmed the correction. Both were useful, but neither replaced my responsibility to understand what the tests actually proved. I had reviewed the results without looking closely enough at this particular assertion.\n\nWhat I'm beginning to question is not only an individual test, but how I organize verification work. I had accumulated checks for the site as a whole. For future changes, I want to try a more gradual approach: agree on the expected behavior for a small piece of work, check that behavior before moving on, and use the broader suite to catch regressions. A common verifier can still be part of that approach; it just shouldn't be the only place where I discover whether a requirement was understood correctly.\n\nFor this project, the concrete result was modest but useful: the verifier now distinguishes a translated article destination from an existing but incorrect homepage destination. The broader lesson I'm taking into future projects is to treat passing tests as evidence to examine, not as proof that the requirement was tested.\n\nThis experience also changed how I think about using GitHub Copilot CLI. I had focused on what I could delegate and automate. I'm now beginning to pay more attention to how I define the work, review the evidence, and decide when a result is good enough to accept.", "url": "https://wpnews.pro/news/the-test-that-passed-without-testing-the-requirement", "canonical_source": "https://dev.to/yonka/the-test-that-passed-without-testing-the-requirement-na5", "published_at": "2026-11-24 20:31:39+00:00", "updated_at": "2026-11-24 20:44:30.895894+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents"], "entities": ["GitHub Copilot CLI", "Astro", "yonka.dev", "GitHub"], "also_reported_by": [], "takeaway": "Verify the element users actually click, not adjacent metadata: compare the visible language switcher's href against an expected path defined outside the generated HTML, since a link and its destination both existing does not prove it leads to the right page.", "recommendation": {"advice": "When writing automated checks for generated pages, assert the visible element's href against an independently defined expected path, not just that the link or its destination exists.", "playbook": "output-verification", "playbook_url": "https://wpnews.pro/playbooks/output-verification"}, "alternates": {"html": "https://wpnews.pro/news/the-test-that-passed-without-testing-the-requirement", "markdown": "https://wpnews.pro/news/the-test-that-passed-without-testing-the-requirement.md", "text": "https://wpnews.pro/news/the-test-that-passed-without-testing-the-requirement.txt", "jsonld": "https://wpnews.pro/news/the-test-that-passed-without-testing-the-requirement.jsonld"}}