Problem
The Neo.mjs repository currently lacks a dedicated learning guide or tutorial on how to write unit tests for components. While a testing framework (Siesta) is in place, there is no documentation explaining how developers can use it to test their own class-based or functional components. This is a significant barrier for new contributors and developers who want to build robust, well-tested applications.
Solution
Create a new learning guide in the learn/guides section titled "Unit Testing with Siesta". This guide should provide a comprehensive, step-by-step introduction to the testing workflow in Neo.mjs.
Content Outline
The guide should cover the following topics:
Introduction to Siesta:
- Brief overview of the Siesta testing framework and its role in the Neo.mjs ecosystem.
- Explanation of the test runner and where to view test results.
Setting Up a New Test:
- How to create a new test file.
- How to add the new test file to the test plan in
test/siesta/siesta.js.
Writing a Basic Test:
- Anatomy of a Siesta test file (
t => {}).
- Writing a simple test for a
Neo.core.Base extension.
- Common assertion methods (
t.is(), t.ok(), t.it(), etc.).
Testing Class-Based Components:
- How to instantiate a component for testing.
- Testing component configuration and default values.
- Testing component methods.
- Testing
afterSet hooks and reactivity.
Testing Functional Components:
- How to render a functional component for testing.
- Testing the output of the
createVdom method.
- Testing component props and reactivity.
Advanced Topics & Best Practices:
- Asynchronous testing (
async/await with t.waitFor()).
- Mocking dependencies.
- Organizing tests with
t.describe().
Acceptance Criteria
- A new markdown file is created at
learn/guides/testing/UnitTestingWithSiesta.md.
- The guide follows the proposed content outline.
- The guide includes clear, runnable code examples.
- The new guide is added to the
learn/tree.json file to appear in the documentation navigation.
Problem
The Neo.mjs repository currently lacks a dedicated learning guide or tutorial on how to write unit tests for components. While a testing framework (Siesta) is in place, there is no documentation explaining how developers can use it to test their own class-based or functional components. This is a significant barrier for new contributors and developers who want to build robust, well-tested applications.
Solution
Create a new learning guide in the
learn/guidessection titled "Unit Testing with Siesta". This guide should provide a comprehensive, step-by-step introduction to the testing workflow in Neo.mjs.Content Outline
The guide should cover the following topics:
Introduction to Siesta:
Setting Up a New Test:
test/siesta/siesta.js.Writing a Basic Test:
t => {}).Neo.core.Baseextension.t.is(),t.ok(),t.it(), etc.).Testing Class-Based Components:
afterSethooks and reactivity.Testing Functional Components:
createVdommethod.Advanced Topics & Best Practices:
async/awaitwitht.waitFor()).t.describe().Acceptance Criteria
learn/guides/testing/UnitTestingWithSiesta.md.learn/tree.jsonfile to appear in the documentation navigation.