File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /* global Mocha */
2+ /* eslint-disable no-console */
3+ let qaseImport : any ;
4+
5+ try {
6+ // Try to use the qase function from the reporter if available
7+ // This is the recommended way for cypress-qase-reporter 3.0.0+
8+ qaseImport = require ( 'cypress-qase-reporter/mocha' ) . qase ;
9+ } catch ( e ) {
10+ // Fallback to custom implementation if the import fails
11+ }
12+
13+ /**
14+ * Custom wrapper for Qase ID integration.
15+ * If the official reporter is available, it delegates to it.
16+ * Otherwise, it appends the Qase ID to the test title manually.
17+ */
18+ export const qase = ( caseId : number | number [ ] , test : Mocha . Test ) : Mocha . Test => {
19+ if ( qaseImport ) {
20+ try {
21+ return qaseImport ( caseId , test ) ;
22+ } catch ( e ) {
23+ console . warn ( 'Qase reporter import failed at runtime, falling back to manual title update.' ) ;
24+ }
25+ }
26+
27+ // Custom fallback implementation
28+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
29+ if ( ! test || ! test . title ) {
30+ return test ;
31+ }
32+ const caseIds = Array . isArray ( caseId ) ? caseId : [ caseId ] ;
33+
34+ test . title = `${ test . title } (Qase ID: ${ caseIds . join ( ',' ) } )` ;
35+
36+ return test ;
37+ } ;
You can’t perform that action at this time.
0 commit comments