3rd-Eden logo3rd-Eden3rd-Eden

Principal Engineer

← Back to Blog
August 2025

Auto Decline Pull Requests That Do Not Introduce Tests

Prioritizing code quality means every bug fix and new feature must come with tests, fostering a culture where untested pull requests are automatically declined to ensure lasting software integrity.

Tests are the safety net that protects your codebase from unexpected issues and regressions. They provide immediate feedback, ensure business logic remains intact, and make refactoring less risky.

The Cost of Skipping Tests

Skipping tests might save time in the short term, but it leads to technical debt and slows down future development. Unverified changes can cause subtle bugs that are costly to diagnose and fix later.

Enforcing Test Coverage with Danger.js

To make testing a non-negotiable part of your workflow, you can use Danger.js to automate PR checks. Danger.js lets you define rules for pull requests, including requiring tests for every bug fix or new feature. For example, you can write a Danger.js rule that fails the PR if no test files are modified or added:

js
// dangerfile.js
const modifiedFiles = danger.git.modified_files;
const createdFiles = danger.git.created_files;
const testPattern = /__tests__|\.test\.js$/;
const containsTest = [...modifiedFiles, ...createdFiles].some(file => testPattern.test(file));

if (!containsTest) {
  fail('Every PR must include relevant tests. Please add or update tests for your change.');
}

Fostering a Culture of Quality

Automating the rejection of PRs without tests sends a clear message: code quality is a shared responsibility. With a simple Danger.js rule, you can help your team stay focused on long-term quality without compromising on shipping speed.

Run the example or inspect the source inline.

Comments (0)

Comment on GitHub

No comments yet.

Opinions expressed are solely my own and do not express the views or opinions of my employer—including the firmly held belief that spaces are superior to tabs.