Thank you for inviting me to complete this junior developer test challenge! My name is Paolo Jose Geronimo and below is a short write-up of how I fixed the bug and wrote a Cypress test to ensure the bug is fixed.
The first thing I did after starting the development server was to try logging in. After confirming that the log in page does not redirect, I took a look at the code. I noticed that the form in LoginForm.js does nothing upon submit, so I added an onSubmit attribute to the form and wrote the handleSubmit function. App.js uses a "onLogin" prop which I called in the handleSubmit function.
To write the Cypress test, I started by visiting the baseURL which was preconfigured in cypress.config.js. I then added "data-test" attributes to each element I wanted to test. The steps in the test are as follows:
- Check if login form exists
- Type "pjgeronimo" into the username field
- Type "password" into the password field
- Click login
- Check if the welcome header exists
I also created a custom command that shortens getting the data-test element and reduces repetitive code.
Below is a screenshot of the completed and successful test:
One interesting problem I faced during creating the test was that while the page redirected manually, it didn't redirect during the Cypress test. I explained my problem to ChatGPT and pasted in only the code I wrote. Below is the prompt and snippet of the response that solved my problem:
This is a test repository for the zipBoard junior position application process. This project demonstrates a simple React application with a login form and Cypress testing setup.
This repository is for testing purposes only. Please fork this repository to your own account and do not modify this original repository. All your work should be done in your forked version.
To run this project locally, you need to have the following installed:
- Node.js (version 18 or higher)
- npm (comes with Node.js)
- Git
- Fork this repository to your own account
- Clone your forked repository:
git clone <your-forked-repo-url>
- Install dependencies:
npm install
- Start the development server:
The application will be available at http://localhost:3000
npm start
This project uses Cypress for end-to-end testing. To run the tests:
-
Make sure the development server is running (
npm start) -
In a new terminal, you can run Cypress in two ways:
npm run cypress:open
This will open the Cypress Test Runner UI where you can:
- Choose your preferred browser
- See all test files
- Run tests interactively
- Watch tests run in real-time
npm run cypress:run
This will run all tests in the terminal without opening the UI.
npm run test:e2e
This command will:
- Start the development server
- Wait for it to be available
- Run all Cypress tests
- Shut down the server when done
├── src/
│ ├── components/
│ │ ├── LoginForm.js
│ │ ├── LoginForm.css
│ │ ├── Welcome.js
│ │ └── Welcome.css
│ ├── App.js
│ └── App.css
├── cypress/
│ ├── e2e/
│ │ └── login.cy.js
│ └── support/
│ ├── commands.js
│ └── e2e.js
└── package.json
npm start- Runs the app in development modenpm test- Runs the React testing suitenpm run build- Builds the app for productionnpm run cypress:open- Opens Cypress Test Runnernpm run cypress:run- Runs Cypress tests in headless modenpm run test:e2e- Runs Cypress tests with the dev server
This project is for testing purposes only and is not licensed for public use.


