@@ -4,67 +4,119 @@ const { createCypress } = helpers
4
4
const { runIsolatedCypress } = createCypress ( )
5
5
6
6
describe ( 'hooks' , function ( ) {
7
- beforeEach ( function ( ) {
8
- this . editor = { }
9
-
10
- return runIsolatedCypress ( `cypress/fixtures/hook_spec.js` , {
11
- onBeforeRun : ( { win } ) => {
12
- this . win = win
13
-
14
- win . runnerWs . emit . withArgs ( 'get:user:editor' )
15
- . yields ( {
16
- preferredOpener : this . editor ,
17
- } )
18
- } ,
7
+ describe ( 'displays hooks' , function ( ) {
8
+ beforeEach ( function ( ) {
9
+ return runIsolatedCypress ( `cypress/fixtures/hooks/basic_spec.js` )
19
10
} )
20
- } )
21
11
22
- it ( 'displays commands under correct hook' , function ( ) {
23
- cy . contains ( 'tests 1' ) . click ( )
12
+ it ( 'displays commands under correct hook' , function ( ) {
13
+ cy . contains ( 'tests 1' ) . click ( )
24
14
25
- cy . contains ( 'before all' ) . closest ( '.collapsible' ) . should ( 'contain' , 'beforeHook 1' )
26
- cy . contains ( 'before each' ) . closest ( '.collapsible' ) . should ( 'contain' , 'beforeEachHook 1' )
27
- cy . contains ( 'test body' ) . closest ( '.collapsible' ) . should ( 'contain' , 'testBody 1' )
28
- cy . contains ( 'after each' ) . closest ( '.collapsible' ) . should ( 'contain' , 'afterEachHook 1' )
29
- } )
15
+ cy . contains ( 'before all' ) . closest ( '.collapsible' ) . should ( 'contain' , 'beforeHook 1' )
16
+ cy . contains ( 'before each' ) . closest ( '.collapsible' ) . should ( 'contain' , 'beforeEachHook 1' )
17
+ cy . contains ( 'test body' ) . closest ( '.collapsible' ) . should ( 'contain' , 'testBody 1' )
18
+ cy . contains ( 'after each' ) . closest ( '.collapsible' ) . should ( 'contain' , 'afterEachHook 1' )
19
+ } )
30
20
31
- it ( 'displays hooks without number when only one of type' , function ( ) {
32
- cy . contains ( 'tests 1' ) . click ( )
21
+ it ( 'displays hooks without number when only one of type' , function ( ) {
22
+ cy . contains ( 'tests 1' ) . click ( )
33
23
34
- cy . contains ( 'before all' ) . should ( 'not.contain' , '(1)' )
35
- cy . contains ( 'before each' ) . should ( 'not.contain' , '(1)' )
36
- cy . contains ( 'after each' ) . should ( 'not.contain' , '(1)' )
24
+ cy . contains ( 'before all' ) . should ( 'not.contain' , '(1)' )
25
+ cy . contains ( 'before each' ) . should ( 'not.contain' , '(1)' )
26
+ cy . contains ( 'after each' ) . should ( 'not.contain' , '(1)' )
27
+ } )
28
+
29
+ it ( 'displays hooks separately with number when more than one of type' , function ( ) {
30
+ cy . contains ( 'tests 2' ) . click ( )
31
+
32
+ cy . contains ( 'before all (1)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'beforeHook 2' )
33
+ cy . contains ( 'before all (2)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'beforeHook 3' )
34
+ cy . contains ( 'before each (1)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'beforeEachHook 1' )
35
+ cy . contains ( 'before each (2)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'beforeEachHook 2' )
36
+ cy . contains ( 'test body' ) . closest ( '.collapsible' ) . should ( 'contain' , 'testBody 2' )
37
+ cy . contains ( 'after each (1)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'afterEachHook 2' )
38
+ cy . contains ( 'after each (2)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'afterEachHook 1' )
39
+ cy . contains ( 'after all (1)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'afterHook 2' )
40
+ cy . contains ( 'after all (2)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'afterHook 1' )
41
+ } )
37
42
} )
38
43
39
- it ( 'displays hooks separately with number when more than one of type' , function ( ) {
40
- cy . contains ( 'tests 2' ) . click ( )
41
-
42
- cy . contains ( 'before all (1)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'beforeHook 2' )
43
- cy . contains ( 'before all (2)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'beforeHook 3' )
44
- cy . contains ( 'before each (1)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'beforeEachHook 1' )
45
- cy . contains ( 'before each (2)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'beforeEachHook 2' )
46
- cy . contains ( 'test body' ) . closest ( '.collapsible' ) . should ( 'contain' , 'testBody 2' )
47
- cy . contains ( 'after each (1)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'afterEachHook 2' )
48
- cy . contains ( 'after each (2)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'afterEachHook 1' )
49
- cy . contains ( 'after all (1)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'afterHook 2' )
50
- cy . contains ( 'after all (2)' ) . closest ( '.collapsible' ) . should ( 'contain' , 'afterHook 1' )
44
+ describe ( 'open in IDE' , function ( ) {
45
+ beforeEach ( function ( ) {
46
+ this . editor = { }
47
+
48
+ return runIsolatedCypress ( `cypress/fixtures/hooks/basic_spec.js` , {
49
+ onBeforeRun : ( { win } ) => {
50
+ this . win = win
51
+
52
+ win . runnerWs . emit . withArgs ( 'get:user:editor' )
53
+ . yields ( {
54
+ preferredOpener : this . editor ,
55
+ } )
56
+ } ,
57
+ } )
58
+ } )
59
+
60
+ it ( 'creates open in IDE button' , function ( ) {
61
+ cy . contains ( 'tests 1' ) . click ( )
62
+
63
+ cy . get ( '.hook-open-in-ide' ) . should ( 'have.length' , 4 )
64
+ } )
65
+
66
+ it ( 'properly opens file in IDE at hook' , function ( ) {
67
+ cy . contains ( 'tests 1' ) . click ( )
68
+
69
+ cy . contains ( 'Open in IDE' ) . invoke ( 'show' ) . click ( ) . then ( function ( ) {
70
+ expect ( this . win . runnerWs . emit . withArgs ( 'open:file' ) . lastCall . args [ 1 ] . file ) . to . include ( 'basic_spec.js' )
71
+ // chrome sets the column to right before "before("
72
+ // while firefox sets it right after "before("
73
+ expect ( this . win . runnerWs . emit . withArgs ( 'open:file' ) . lastCall . args [ 1 ] . column ) . to . be . eq ( Cypress . browser . family === 'firefox' ? 10 : 3 )
74
+ expect ( this . win . runnerWs . emit . withArgs ( 'open:file' ) . lastCall . args [ 1 ] . line ) . to . be . eq ( 2 )
75
+ } )
76
+ } )
51
77
} )
52
78
53
- it ( 'creates open in IDE button' , function ( ) {
54
- cy . contains ( 'tests 1' ) . click ( )
79
+ describe ( 'skipped tests' , function ( ) {
80
+ beforeEach ( function ( ) {
81
+ return runIsolatedCypress ( `cypress/fixtures/hooks/skip_spec.js` )
82
+ } )
83
+
84
+ it ( 'does not display commands from skipped tests' , function ( ) {
85
+ cy . contains ( 'test 1' ) . click ( )
86
+
87
+ cy . contains ( 'test 1' ) . parents ( '.collapsible' ) . first ( ) . should ( 'not.contain' , 'testBody 1' )
88
+ } )
89
+
90
+ // https://github.com/cypress-io/cypress/issues/8086
91
+ it ( 'displays before hook when following it.skip' , function ( ) {
92
+ cy . contains ( 'test 2' ) . click ( )
55
93
56
- cy . get ( '.hook-open-in-ide' ) . should ( 'have.length' , 4 )
94
+ cy . contains ( 'test 2' ) . parents ( '.collapsible' ) . first ( ) . should ( 'contain' , 'before all' )
95
+ } )
57
96
} )
58
97
59
- it ( 'properly opens file in IDE at hook' , function ( ) {
60
- cy . contains ( 'tests 1' ) . click ( )
98
+ describe ( 'only tests' , function ( ) {
99
+ beforeEach ( function ( ) {
100
+ return runIsolatedCypress ( `cypress/fixtures/hooks/only_spec.js` )
101
+ } )
102
+
103
+ it ( 'only displays tests with .only' , function ( ) {
104
+ cy . contains ( 'test wrapper' ) . parents ( '.collapsible' ) . first ( ) . should ( ( $suite ) => {
105
+ expect ( $suite ) . not . to . contain ( 'test 1' )
106
+ expect ( $suite ) . to . contain ( 'nested suite 1' )
107
+ expect ( $suite ) . to . contain ( 'test 2' )
108
+ expect ( $suite ) . not . to . contain ( 'nested suite 2' )
109
+ expect ( $suite ) . not . to . contain ( 'test 3' )
110
+ expect ( $suite ) . to . contain ( 'nested suite 3' )
111
+ expect ( $suite ) . to . contain ( 'test 4' )
112
+ } )
113
+
114
+ cy . contains ( 'test 2' ) . click ( )
61
115
62
- cy . contains ( 'Open in IDE' ) . invoke ( 'show' ) . click ( ) . then ( function ( ) {
63
- expect ( this . win . runnerWs . emit . withArgs ( 'open:file' ) . lastCall . args [ 1 ] . file ) . to . include ( 'hook_spec.js' )
64
- // chrome sets the column to right before "before("
65
- // while firefox sets it right after "before("
66
- expect ( this . win . runnerWs . emit . withArgs ( 'open:file' ) . lastCall . args [ 1 ] . column ) . to . be . eq ( Cypress . browser . family === 'firefox' ? 10 : 3 )
67
- expect ( this . win . runnerWs . emit . withArgs ( 'open:file' ) . lastCall . args [ 1 ] . line ) . to . be . eq ( 2 )
116
+ cy . contains ( 'test 2' ) . parents ( '.collapsible' ) . first ( ) . should ( ( $test ) => {
117
+ expect ( $test ) . to . contain ( 'before each' )
118
+ expect ( $test ) . to . contain ( 'test body' )
119
+ } )
68
120
} )
69
121
} )
70
122
} )
0 commit comments