@@ -31,6 +31,21 @@ const RUNNABLE_PROPS = [
31
31
const debug = debugFn ( 'cypress:driver:runner' )
32
32
const debugErrors = debugFn ( 'cypress:driver:errors' )
33
33
34
+ // detect studio mode from URL parameters
35
+ const isStudioMode = ( ) => {
36
+ try {
37
+ if ( typeof window === 'undefined' ) return false
38
+
39
+ const url = new URL ( window . location . href )
40
+ const hashParams = new URLSearchParams ( url . hash . slice ( 1 ) )
41
+
42
+ // studio mode is active if there's a 'studio' parameter
43
+ return hashParams . has ( 'studio' )
44
+ } catch ( err ) {
45
+ return false
46
+ }
47
+ }
48
+
34
49
const RUNNER_EVENTS = [
35
50
TEST_BEFORE_RUN_ASYNC_EVENT ,
36
51
TEST_BEFORE_RUN_EVENT ,
@@ -636,7 +651,7 @@ const pruneEmptySuites = (rootSuite, testFilter: NonNullable<TestFilter>) => {
636
651
return totalUnfilteredTests
637
652
}
638
653
639
- const normalizeAll = ( suite , initialTests = { } , testFilter , setTestsById , setTests , getRunnableId , getHookId , setOnlyTestId , getOnlyTestId , getNewTestLineNumber ) => {
654
+ const normalizeAll = ( suite , initialTests = { } , testFilter , setTestsById , setTests , getRunnableId , getHookId , setOnlyTestId , getOnlyTestId , getNewTestLineNumber , getIsStudioCreatedTest ) => {
640
655
let totalUnfilteredTests = 0
641
656
642
657
// Empty suites don't have any impact in run mode so let's avoid this extra work.
@@ -662,7 +677,7 @@ const normalizeAll = (suite, initialTests = {}, testFilter, setTestsById, setTes
662
677
// traversing through it multiple times
663
678
const tests : Record < string , any > = { }
664
679
665
- const normalizedSuite = normalize ( suite , tests , initialTests , getRunnableId , getHookId , setOnlyTestId , getOnlyTestId , getNewTestLineNumber )
680
+ const normalizedSuite = normalize ( suite , tests , initialTests , getRunnableId , getHookId , setOnlyTestId , getOnlyTestId , getNewTestLineNumber , getIsStudioCreatedTest )
666
681
667
682
if ( setTestsById ) {
668
683
// use callback here to hand back
@@ -702,7 +717,7 @@ const normalizeAll = (suite, initialTests = {}, testFilter, setTestsById, setTes
702
717
return normalizedSuite
703
718
}
704
719
705
- const normalize = ( runnable , tests , initialTests , getRunnableId , getHookId , setOnlyTestId , getOnlyTestId , getNewTestLineNumber ) => {
720
+ const normalize = ( runnable , tests , initialTests , getRunnableId , getHookId , setOnlyTestId , getOnlyTestId , getNewTestLineNumber , getIsStudioCreatedTest ) => {
706
721
const normalizeRunnable = ( runnable ) => {
707
722
if ( ! runnable . id ) {
708
723
runnable . id = getRunnableId ( )
@@ -771,7 +786,9 @@ const normalize = (runnable, tests, initialTests, getRunnableId, getHookId, setO
771
786
setOnlyTestId ( runnable . id )
772
787
}
773
788
774
- if ( ( runnable . type !== 'suite' ) || ! hasOnly ( runnable ) ) {
789
+ const shouldBypassOnly = ( isStudioMode ( ) && getIsStudioCreatedTest ( ) )
790
+
791
+ if ( ( runnable . type !== 'suite' ) || ! hasOnly ( runnable ) || shouldBypassOnly ) {
775
792
if ( runnable . type === 'test' && ( ! getOnlyTestId ( ) || runnable . id === getOnlyTestId ( ) ) ) {
776
793
push ( runnable )
777
794
}
@@ -792,7 +809,7 @@ const normalize = (runnable, tests, initialTests, getRunnableId, getHookId, setO
792
809
_ . each ( { tests : runnableTests , suites : runnableSuites } , ( _runnables , type ) => {
793
810
if ( runnable [ type ] ) {
794
811
return normalizedRunnable [ type ] = _ . compact ( _ . map ( _runnables , ( childRunnable ) => {
795
- const normalizedChild = normalize ( childRunnable , tests , initialTests , getRunnableId , getHookId , setOnlyTestId , getOnlyTestId , getNewTestLineNumber )
812
+ const normalizedChild = normalize ( childRunnable , tests , initialTests , getRunnableId , getHookId , setOnlyTestId , getOnlyTestId , getNewTestLineNumber , getIsStudioCreatedTest )
796
813
797
814
if ( type === 'tests' && onlyIdMode ( ) ) {
798
815
if ( normalizedChild . id === getOnlyTestId ( ) ) {
@@ -881,7 +898,7 @@ const normalize = (runnable, tests, initialTests, getRunnableId, getHookId, setO
881
898
suite . suites = [ ]
882
899
883
900
normalizedSuite . suites = _ . compact ( _ . map ( suiteSuites , ( childSuite ) => {
884
- const normalizedChildSuite = normalize ( childSuite , tests , initialTests , getRunnableId , getHookId , setOnlyTestId , getOnlyTestId , getNewTestLineNumber )
901
+ const normalizedChildSuite = normalize ( childSuite , tests , initialTests , getRunnableId , getHookId , setOnlyTestId , getOnlyTestId , getNewTestLineNumber , getIsStudioCreatedTest )
885
902
886
903
if ( ( suite . _onlySuites . indexOf ( childSuite ) !== - 1 ) || filterOnly ( normalizedChildSuite , childSuite ) ) {
887
904
if ( onlyIdMode ( ) ) {
@@ -1314,6 +1331,7 @@ export default {
1314
1331
let _startTime : string | null = null
1315
1332
let _onlyTestId = null
1316
1333
let _newTestLineNumber = null
1334
+ let _isStudioCreatedTest = false
1317
1335
1318
1336
const getRunnableId = ( ) => {
1319
1337
return `r${ ++ _runnableId } `
@@ -1378,6 +1396,12 @@ export default {
1378
1396
1379
1397
const getNewTestLineNumber = ( ) => _newTestLineNumber
1380
1398
1399
+ const setIsStudioCreatedTest = ( isCreated ) => {
1400
+ _isStudioCreatedTest = isCreated
1401
+ }
1402
+
1403
+ const getIsStudioCreatedTest = ( ) => _isStudioCreatedTest
1404
+
1381
1405
const abort = ( ) => {
1382
1406
// abort the run
1383
1407
_runner . abort ( )
@@ -1562,6 +1586,8 @@ export default {
1562
1586
setOnlyTestId,
1563
1587
setNewTestLineNumber,
1564
1588
getNewTestLineNumber,
1589
+ setIsStudioCreatedTest,
1590
+ getIsStudioCreatedTest,
1565
1591
normalizeAll ( tests , skipCollectingLogs , testFilter ) {
1566
1592
_skipCollectingLogs = skipCollectingLogs
1567
1593
// if we have an uncaught error then slice out
@@ -1590,6 +1616,7 @@ export default {
1590
1616
setOnlyTestId ,
1591
1617
getOnlyTestId ,
1592
1618
getNewTestLineNumber ,
1619
+ getIsStudioCreatedTest ,
1593
1620
)
1594
1621
} ,
1595
1622
0 commit comments