diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php
index f924a7dc03..eccf49354f 100644
--- a/tests/phpunit/includes/bootstrap.php
+++ b/tests/phpunit/includes/bootstrap.php
@@ -32,7 +32,7 @@ if ( ! is_readable( $config_file_path ) ) {
 require_once $config_file_path;
 require_once dirname( __FILE__ ) . '/functions.php';
 
-if ( file_exists( ABSPATH . '_index.php' ) ) {
+if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && file_exists( ABSPATH . '_index.php' ) ) {
 	// Perhaps add more documentation about having to run `grunt` before running tests after changing code.
 	echo "ERROR: ABSPATH must point to the `build` directory, not the `src` directory. Please update your wp-tests-config.php file.\n";
 	exit( 1 );
diff --git a/wp-tests-config-sample.php b/wp-tests-config-sample.php
index fd1ccd0d61..083d6b3efd 100644
--- a/wp-tests-config-sample.php
+++ b/wp-tests-config-sample.php
@@ -1,7 +1,11 @@
 <?php
 
 /* Path to the WordPress codebase you'd like to test. Add a forward slash in the end. */
-define( 'ABSPATH', dirname( __FILE__ ) . '/build/' );
+if ( is_dir( dirname( __FILE__ ) . '/build/' ) ) {
+	define( 'ABSPATH', dirname( __FILE__ ) . '/build/' );
+} else {
+	define( 'ABSPATH', dirname( __FILE__ ) . '/src/' );
+}
 
 /*
  * Path to the theme to test with.
