Now that you have covered creating a testing suite, we can use the key principles of test-driven development to work with an existing app. Normally, you would build the testing while developing, but you were recently brought onto this project to add a testing suite! You are working to implement a testing suite for a banking application that allows users to track their expenditures by submitting and searching through them.
- Build a testing suite for an existing application.
- Identify the key features of this project.
- One feature needs to be completed: the search functionality.
- Build a test suite using Vitest to test key features:
- Display transactions
- Add transactions
- Search transactions and sort transactions
- Commit as you go, writing meaningful commit messages.
- Push commit history to GitHub periodically and when the lab is complete.
- Vitest: Vitest Documentation
Before we begin coding, let's complete the initial setup for this lesson:
- Go to the provided GitHub repository link.
- Fork the repository to your GitHub account.
- Clone the forked repository to your local machine.
- Open the project in VSCode.
- Run
npm install
to install all necessary dependencies.
- Build a testing suite for an existing application.
- Identify the key features of this project.
- Open the React application in the browser:
npm run dev
- Run the included backend:
npm run server
- Create a test branch.
- Create a test suite that will test if transactions are displayed on startup.
- Create a test suite that will test:
- If new transactions are added to the frontend.
- If a POST request was called.
- Create a test suite that will test:
- If a change event is triggered, the page updates accordingly.
- Search is incomplete, so build out the search functionality based on the test.
- Push the feature branch and open a PR on GitHub.
- Merge to
main
.
- Add comments to the code to explain purpose and logic.
- Clarify intent/functionality of code for other developers.
- Add screenshots of completed work included in Markdown in
README.md
. - Update
README.md
to reflect the functionality of the application following Make a README. - Delete any stale branches on GitHub.
- Remove unnecessary/commented-out code.
- If needed, update
.gitignore
to remove sensitive data.
- Once the test suite is built, submit the link to the GitHub repository on Canvas.
- The application has test suites.
- The application tests if transactions display on load.
- The application tests if a new transaction can be added.
- The application tests if search functionality updates the page correctly.