This project is designed to perform automated testing of the Star Wars API (SWAPI) using TypeScript, Jest, and Axios.
swapi-api-tests/
├── src/
│ ├── api/ # API client
│ ├── models/ # TypeScript interfaces for API responses
│ ├── tests/ # Test files
│ └── utils/ # Utility functions and helpers
├── config/ # Configuration file
├── report/ # Test reports (generated after running tests)
├── .eslintrc.js # ESLint configuration file
├── jest.config.js # Jest configuration file
├── tsconfig.json # TypeScript configuration file
└── package.json # Project metadata and scripts
- Node.js: Version 22
- Yarn: Package manager for installing dependencies
- Windows: PowerShell or Command Prompt
- MacBook: Terminal
- VS Code or any other IDEs to look at the project structure
- Clone the repository
swapi-api-tests
- Navigate to
swapi-api-tests
on your Terminal/Powershell - Install all the dependencies with the below command
yarn install
- Run the API tests with command
yarn test
- On completion of the tests, test report is generated in the folder
report
. You can openreport.html
to read the reports. - We can also run the tests in debug mode which runs whenever the code is changed
yarn test:watch
- To make sure that the coding style remains the same for everyone, eslint and prettier rules have been set up in the project.
- ESLint: Lints JavaScript and TypeScript code to catch errors and enforce coding standards.
- Prettier: Automatically formats code to maintain a consistent style.
- To run the linting you can run the command:
yarn lint
- To fix the linting errors, you can run the command:
yarn lint:fix
- To format the code as per prettier settings, you can run:
yarn format
- The project is integrated with GitHub Actions to automate test execution on each push and on creation of pull request. This provides immediate feedback on test results, ensuring code quality and functionality.
- You can see the tests run on GitHub Actions here.
- We also have html reports for each test run uploaded as an artifact, that you can find in the example link here in the
Artifacts
section. - Alternatively, we can also view the test results for each test runs in
API Test Report
section in the job itself like in this example.
- You can find more details on the project and test cases below: