@@ -3,6 +3,8 @@ const snapshot = require('snap-shot-it')
33import { SpawnOptions } from 'child_process'
44import { expect } from './spec_helper'
55
6+ const isCi = require ( 'is-ci' )
7+
68require ( 'mocha-banner' ) . register ( )
79const chalk = require ( 'chalk' ) . default
810const _ = require ( 'lodash' )
@@ -525,7 +527,7 @@ const copy = function () {
525527 }
526528}
527529
528- const getMochaItFn = function ( only , skip , browser , specifiedBrowser ) {
530+ const getMochaItFn = function ( title , only , skip , browser , specifiedBrowser ) {
529531 // if we've been told to skip this test
530532 // or if we specified a particular browser and this
531533 // doesn't match the one we're currently trying to run...
@@ -535,6 +537,12 @@ const getMochaItFn = function (only, skip, browser, specifiedBrowser) {
535537 }
536538
537539 if ( only ) {
540+ if ( isCi ) {
541+ // fixes the problem where systemTests can accidentally by skipped using systemTests.it.only(...)
542+ // https://github.com/cypress-io/cypress/pull/20276
543+ throw new Error ( `the system test: "${ chalk . yellow ( title ) } " has been set to run with an it.only() which is not allowed in CI environments.\n\nPlease remove the it.only()` )
544+ }
545+
538546 return it . only
539547 }
540548
@@ -605,7 +613,7 @@ const localItFn = function (title: string, opts: ItOptions) {
605613 const browsersToTest = getBrowsers ( options . browser )
606614
607615 const browserToTest = function ( browser ) {
608- const mochaItFn = getMochaItFn ( options . only , options . skip , browser , specifiedBrowser )
616+ const mochaItFn = getMochaItFn ( title , options . only , options . skip , browser , specifiedBrowser )
609617
610618 const testTitle = `${ title } [${ browser } ]`
611619
0 commit comments