@@ -8,11 +8,12 @@ import {
8
8
Status ,
9
9
Category ,
10
10
LabelName ,
11
+ LinkType ,
11
12
} from '../plugins/allure-types' ; // todo
12
13
import { registerScreenshotHandler } from './screenshots' ;
13
14
import StatusDetails = Cypress . StatusDetails ;
14
15
import { logClient } from './helper' ;
15
- import { tmsIssueUrl } from '../common' ;
16
+ import { packageLog , tmsIssueUrl } from '../common' ;
16
17
import { EventEmitter } from 'events' ;
17
18
import AllureEvents = Cypress . AllureEvents ;
18
19
@@ -126,10 +127,22 @@ export const allureInterface = (
126
127
} ,
127
128
128
129
link : ( url : string , name ?: string , type ?: 'issue' | 'tms' ) => fn ( { task : 'link' , arg : { url, name, type } } ) ,
129
- tms : ( url : string , name ?: string ) =>
130
- fn ( { task : 'link' , arg : { url : tmsIssueUrl ( env , url , 'tms' ) , name : name ?? url , type : 'tms' } } ) ,
131
- issue : ( url : string , name ?: string ) =>
132
- fn ( { task : 'link' , arg : { url : tmsIssueUrl ( env , url , 'issue' ) , name : name ?? url , type : 'issue' } } ) ,
130
+ tms : ( url : string , name ?: string ) => {
131
+ const type : LinkType = 'tms' ;
132
+ const fullUrl = tmsIssueUrl ( env , url , type ) ;
133
+ const linkName = name ?? url ;
134
+
135
+ return fn ( { task : 'link' , arg : { url : fullUrl , name : linkName , type } } ) ;
136
+ } ,
137
+
138
+ issue : ( url : string , name ?: string ) => {
139
+ const type : LinkType = 'issue' ;
140
+ const fullUrl = tmsIssueUrl ( env , url , type ) ;
141
+ const linkName = name ?? url ;
142
+
143
+ return fn ( { task : 'link' , arg : { url : fullUrl , name : linkName , type } } ) ;
144
+ } ,
145
+
133
146
label : ( name : string , value : string ) => fn ( { task : 'label' , arg : { name, value } } ) ,
134
147
suite : ( name : string ) => fn ( { task : 'suite' , arg : { name } } ) ,
135
148
parentSuite : ( name : string ) => fn ( { task : 'parentSuite' , arg : { name } } ) ,
@@ -176,7 +189,7 @@ const isHook = (test: Mocha.Test) => {
176
189
return ( test as any ) . type === 'hook' ;
177
190
} ;
178
191
179
- const createTests = ( runner : Mocha . Runner , test : Mocha . Test ) => {
192
+ const createTestsForFailedBeforeHook = ( runner : Mocha . Runner , test : Mocha . Test ) => {
180
193
let index = 0 ;
181
194
test . parent ?. eachTest ( ts => {
182
195
ts . err = test . err ;
@@ -186,6 +199,15 @@ const createTests = (runner: Mocha.Runner, test: Mocha.Test) => {
186
199
if ( ts ) {
187
200
if ( index === 1 ) {
188
201
ts . state = 'failed' ;
202
+
203
+ if ( ts . err ) {
204
+ // Cypress error cannot be taken here - it will be updated only on 'test:after:run' event
205
+ // so to simplify events chain creating own error message
206
+ // need to watch cypress error text message when it changes - and update it here
207
+ ts . err . message =
208
+ `${ ts . err . message } \n\n` +
209
+ `Because this error occurred during a \`before all\` hook we are skipping the remaining tests in the current suite: \`${ ts . parent ?. title } \` (added by ${ packageLog } )` ;
210
+ }
189
211
}
190
212
runner . emit ( CUSTOM_EVENTS . TEST_BEGIN , ts ) ;
191
213
runner . emit ( CUSTOM_EVENTS . TEST_FAIL , ts ) ;
@@ -393,7 +415,8 @@ export const registerMochaReporter = (ws: WebSocket) => {
393
415
return ;
394
416
}
395
417
396
- createTestsCallb = ( ) => createTests ( runner , test ) ;
418
+ runner . emit ( CUSTOM_EVENTS . TEST_END , test ) ;
419
+ createTestsForFailedBeforeHook ( runner , test ) ;
397
420
398
421
return ;
399
422
}
0 commit comments