Learn how to configure code coverage reporting in Replit for comprehensive testing, ensuring improved software quality and reliability with detailed insights.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
When undertaking software development in Replit, ensuring comprehensive testing through code coverage is crucial. Code coverage provides insights into which parts of your codebase are tested, thus helping improve the quality and reliability of your software.
pip install coverage
to install coverage.py.npm install --save-dev nyc
to install nyc.
.coveragerc
file in your project’s root directory to specify which files and directories should be included or omitted.package.json
to include configuration settings for nyc, specifying include/exclude patterns..coveragerc
:
<pre>
[run]
branch = True
source = my_project
[report]
omit =
tests/*
</pre>
package.json
entry for nyc:
<pre>
"nyc": {
"include": [
"src/*/.js"
],
"exclude": [
"test/*/.js"
]
}
</pre>
coverage run -m pytest
to execute your tests with coverage tracking.test
script in package.json
to use nyc: "test": "nyc mocha"
coverage report
for a text-based output or coverage html
for an HTML page.nyc report --reporter=text
or nyc report --reporter=html
to create text-based or HTML reports.
<pre>
name: Python application
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest coverage
- name: Run tests
run: |
coverage run -m pytest
coverage report
</pre>
By meticulously configuring and utilizing code coverage reporting in Replit, you can significantly enhance your project's reliability and maintainability. Remember, thorough testing and high coverage percentages are pivotal to delivering robust and error-free software.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.