Skip to content

Commit 9a8987e

Browse files
authored
chore: remove system test it.only and prevent CI from ever running onlys (#20276)
* remove accidental system test it.only * prevent system tests from running in CI if set to run exclusively with it.only(...)
1 parent 01fc857 commit 9a8987e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

system-tests/lib/system-tests.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const snapshot = require('snap-shot-it')
33
import { SpawnOptions } from 'child_process'
44
import { expect } from './spec_helper'
55

6+
const isCi = require('is-ci')
7+
68
require('mocha-banner').register()
79
const chalk = require('chalk').default
810
const _ = 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

system-tests/test/deprecated_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('deprecated before:browser:launch args', () => {
5050
psInclude: ['--foo', '--bar'],
5151
})
5252

53-
systemTests.it.only('concat return returns once', {
53+
systemTests.it('concat return returns once', {
5454
// TODO: implement webPreferences.additionalArgs here
5555
// once we decide if/what we're going to make the implemenation
5656
// SUGGESTION: add this to Cypress.browser.args which will capture

0 commit comments

Comments
 (0)