AI-Generated Frontend Code: Testing What Works and What Still Needs a Developer

    A hands-on test of an AI code generation model on a production-like frontend project (login page, product list page, and a complex form page). The results show that AI can reliably scaffold basic pages, but interactive filtering logic, form validation rules, and field dependencies are often missing. This article breaks down the observed gaps, compares generation time with a leading closed-source model, and shares practical tips for writing better prompts and verifying AI-generated code before deployment.

    Test Setup

    This test used a production-like frontend requirement covering three pages: a login page, a product list page, and a complex form page. The requirement was submitted to the model as a document, and the model was asked to output a complete, deployable project rather than scattered code snippets.

    The original test did not consistently record model names, versions, full prompts, or frontend framework versions, so the sections below only describe observed behavior without ranking any models. During testing, the system showed a queue message at peak resource hours, and it took roughly 30 minutes from submission to a live project, including queue time. The same requirement had previously been run on another leading closed-source model, which generated the project in about 3 minutes. The two measurements were not taken under strictly aligned conditions, so these numbers should be treated as reference points only.

    Login Page: Basic Structure Works

    The login page included a carousel background, form inputs, and basic interactions. The model showed a solid understanding of this page type: both the carousel and the form layout were implemented as required, with no obvious omissions. The code quality was close to “minor tweaks before going live.”

    Pages like this have a fixed structure that the model can handle with well-established patterns, making them a good fit for saving setup time. Before launch, you should still check how the styles behave at different screen widths and confirm that error messages appear correctly when form submission fails.

    Product List Page: Filtering Logic Missing

    The list page requirement defined three types of filters—status, time range, and category tags—and required them to work together. For example, selecting a category should update the available time range options. The generated page had the right overall structure with the table and pagination in place, but the filter components were entirely absent from the generated code.

    This issue appeared repeatedly across multiple list page generations. One possible explanation is that when a long prompt spends most of its length on visual styles and data structures, the model may prioritize page presentation and pay less attention to interaction rules scattered throughout the text. This is only a hypothesis and has not been verified through controlled experiments. A way to verify it would be to move the filtering requirements to the very beginning of the prompt, or remove the style descriptions entirely and regenerate, then observe whether the filters appear.

    Form Page: Validation and Field Linkage Missing

    The form page is the strongest test of detail reproduction. The requirement stated that selecting a specific value in a dropdown should reveal three related input fields and apply regex validation to their contents. The pseudocode below illustrates the expected logic from the requirement. It is for explanation only and cannot be run:

    1. // Pseudocode: expected logic from the requirement
    2. if (formData.type === 'specific') {
    3. showRelatedFields();
    4. validateField('relatedField1', /^[A-Za-z0-9]+$/);
    5. }

    The generated code kept only the conditionally rendered input fields. The validation rules and the corresponding state management were missing. The form rendered correctly, but submitting invalid input was never blocked.

    Overall Comparison

    Observation Model Tested This Time Another Leading Closed-Source Model (Previous Test Record)
    Project generation time ~30 minutes (including queue) ~3 minutes
    List page filter linkage Filters missing Field relationships and interaction details reproduced
    Form page validation rules Rules missing Validation and field relationships reproduced
    Visual quality Serviceable, no major issues Not separately recorded in the previous test

    The overall visual style was usable but still behind mature component libraries or CSS framework templates. It works better as an “engineering-ready” starting point than as a finished deliverable.

    How to Write the Prompt

    This test suggests that how you structure the requirement document significantly affects the results. A few recommendations:

    1. Page inventory: List the modules on each page one by one—for example, the login page includes a carousel, account input, password input, and a login button.
    2. Interaction rules: Write each interaction in “trigger, result” form—for example, “after a category is selected, the time range options update accordingly.”
    3. Validation rules: Specify the rule, regex, and error message text for every field.
    4. Field dependencies: List dependent fields and state which field’s change affects which other field.
    5. Separate sections: Keep business rules and style descriptions apart so interaction requirements don’t get buried under long blocks of styling text.
    6. Responsive requirements: State the target screen widths and how the layout should adapt.

    Pre-Launch Checks

    AI-generated code should never go live as-is. At minimum, complete three types of checks:

    • Manual code review: Confirm that every requirement item has a corresponding implementation, focusing on interaction and validation logic.
    • Security review: Confirm that inputs are also validated outside the frontend, that APIs enforce authentication, and that no secrets or sensitive information exist in the frontend code.
    • Regression testing: Write test cases for filtering, field linkage, failed submissions, and similar paths, and verify each one.

    About Open-Source Models

    Open-source models make code generation more accessible to small teams and individual developers. The community may eventually fine-tune models to address common weaknesses like list filtering and form validation, but this test did not verify that. A more practical approach for developers is to build a fixed test set based on your own requirements, compare different models against it, and then decide which one to adopt.

    Conclusion

    Current large language models can handle basic page scaffolding quite well. For complex interactions and validation rules, they still need developers to write clearer requirements and perform manual review. Writing precise prompts, keeping tests, and recording test conditions are the baseline practices for determining whether a model is ready for your workflow.