A simple REST API for managing books.
-
Clone the repository:
git clone https://github.com/Aviv-public/aviv-qa-api-technical-test.git cd aviv-qa-api-technical-test
-
Setup environment:
cp .env.example .env
Configure your .env file with appropriate values:
API_KEY=your-secure-api-key-here
-
Install dependencies and start:
npm install npm run start
The API will be running at http://localhost:3000
The API documentation will be available at http://localhost:3000/api-docs
All API endpoints (except documentation) require authentication using an API key header:
x-api-key: default-secure-api-key-2024
The API is documented using Swagger. You can access the interactive documentation at:
- Swagger UI:
http://localhost:3000/api-docs
To explore the API:
- Start the server using
npm start
- Open your browser and navigate to
http://localhost:3000/api-docs
- Use the Swagger UI to check the endpoints and view request/response schemas
The API provides the following endpoints:
- GET / - Welcome page
- GET /api/books - List all books
- POST /api/books - Create a new book
- GET /api/books/:id - Get a book by ID
- PUT /api/books/:id - Update a book
- FETCH /api/books/:id - Fetch a book
- DELETE /api/books/:id - Delete a book
Note: All /api/* endpoints require authentication via x-api-key header.
To run the tests, use the following command:
npm test
QA Engineers, responsible for ensuring the quality and functionality of the API, should follow test automation best practices including:
-
Page Object Pattern
- Create separate classes for each API endpoint
- Encapsulate API calls and assertions
- Maintain clean separation of concerns
-
Data-Driven Testing
- Use test data providers
- Cover multiple scenarios and edge cases
- Include both valid and invalid test cases
-
Test Flow Requirements
- Implement end-to-end flows (e.g., CRUD operations)
- Chain API calls using previous responses:
// Example flow const book = await createBook(testData); const retrieved = await getBook(book.id); const updated = await updateBook(book.id, newData); await deleteBook(book.id);
- Validate response schemas and status codes
-
Coverage Requirements
- Cover all endpoints in the API
- Include positive and negative scenarios
-
Technical Stack (Optional)
- Language: TypeScript
- Test Framework: Jest
- API Testing Libraries:
supertest
- HTTP assertions@faker-js/faker
- Test data generationjoi
- Schema validation
-
Fork the repository: Go to the repository on GitHub and click the "Fork" button to create a copy of the repository in your own GitHub account.
-
Clone your forked repository:
git clone https://github.com/username/aviv-qa-api-technical-test.git cd aviv-qa-api-technical-test
-
Create a new branch:
git checkout -b test-branch-name
-
Add your test cases: Add your test cases in the
tests
directory. -
Commit your changes:
git add . git commit -m "Add test cases"
-
Create a GitHub Actions workflow: In the root of your repository, create a directory named
.github/workflows
if it doesn't already exist. Inside this directory, create a file namedci.yml
. -
Push your branch:
git push origin test-branch-name
-
Create a pull request: Go to the repository on GitHub and create a pull request to merge your test branch into the main branch.
This project is licensed under the MIT License.