Prerequisites
Ensure that you have the following installed on your machine:
- Node.js: Required for running TypeScript and JavaScript tests.
- Python: Necessary for running Python-based tests.
- Docker: To build and run the Docker container that exposes port 3000.
Step 1: Clone the Repository
Clone the repository to your local machine if you haven’t already.
git clone https://github.com/pingcap/autoflow.git
cd autoflow
Step 2: Install Dependencies
Use npm or yarn to install the project dependencies. This step is crucial for both TypeScript and JavaScript tests.
npm install
# or
yarn install
Step 3: Running TypeScript Tests
The TypeScript tests can be run using Jest, which is typically set up in the project. To execute the tests, use the following command:
npm run test
# or
yarn test
For a more detailed output, you can add the --verbose
flag:
npm run test -- --verbose
Step 4: Running Python Tests
If there are Python tests in the project, you might use pytest as the test runner. Ensure that pytest is installed:
pip install pytest
Then, navigate to the directory containing the Python files and run:
pytest
Step 5: Running Docker Tests
If the project includes tests that are configured to run within a Docker container, you will first need to build the Docker image. Use the following command while in the project’s root directory:
docker build -t autoflow .
Once the image is built, run the container, exposing port 3000 as specified:
docker run -p 3000:3000 autoflow
After the container is running, access the application through your browser or through cURL on http://localhost:3000
.
Step 6: Check Test Coverage
To check test coverage for the TypeScript tests, Jest can provide a coverage report. Run the following command:
npm run test -- --coverage
This command will generate a coverage report, typically in the coverage
directory.
Step 7: Continuous Integration
Ensure the project is set up for continuous integration, if applicable. Check the relevant CI configuration files (e.g., .github/workflows
, .gitlab-ci.yml
) to verify that test commands are being invoked correctly upon commits.
Conclusion
Make sure to pay attention to any specifics outlined in the project documentation or README regarding testing frameworks or conventions. Keeping dependencies up-to-date is essential for ensuring smooth execution of tests and avoiding conflicts.
Source: Information taken from the PingCAP Autoflow repository guidelines.