@@ -117,23 +117,35 @@ declare module 'jest-allure2-reporter' {
117
117
*/
118
118
subDir ?: string ;
119
119
/**
120
- * Specifies strategy for attaching files to the report by their path.
120
+ * Specifies default strategy for attaching files to the report by their path.
121
121
* - `copy` - copy the file to {@link AttachmentsOptions#subDir}
122
122
* - `move` - move the file to {@link AttachmentsOptions#subDir}
123
123
* - `ref` - use the file path as is
124
124
* @default 'ref'
125
125
* @see {@link AllureRuntime#createFileAttachment }
126
126
*/
127
- fileHandler ?: BuiltinFileHandler ;
127
+ fileHandler ?: BuiltinFileAttachmentHandler | string ;
128
+ /**
129
+ * Specifies default strategy for attaching dynamic content to the report.
130
+ * Uses simple file writing by default.
131
+ */
132
+ contentHandler ?: BuiltinContentAttachmentHandler | string ;
128
133
} ;
129
134
130
135
/** @see {@link AttachmentsOptions#fileHandler } */
131
- export type BuiltinFileHandler = 'copy' | 'move' | 'ref' ;
136
+ export type BuiltinFileAttachmentHandler = 'copy' | 'move' | 'ref' ;
137
+
138
+ /** @see {@link AttachmentsOptions#contentHandler } */
139
+ export type BuiltinContentAttachmentHandler = 'write' ;
132
140
133
141
/**
134
142
* Global customizations for how test cases are reported
135
143
*/
136
144
export interface TestCaseCustomizer {
145
+ /**
146
+ * Extractor to omit test file cases from the report.
147
+ */
148
+ hidden : TestCaseExtractor < boolean > ;
137
149
/**
138
150
* Test case ID extractor to fine-tune Allure's history feature.
139
151
* @example ({ package, file, test }) => `${package.name}:${file.path}:${test.fullName}`
@@ -228,9 +240,9 @@ declare module 'jest-allure2-reporter' {
228
240
*/
229
241
export interface TestFileCustomizer {
230
242
/**
231
- * Extractor to omit test cases from the report.
243
+ * Extractor to omit test file cases from the report.
232
244
*/
233
- ignored : TestFileExtractor < boolean > ;
245
+ hidden : TestFileExtractor < boolean > ;
234
246
/**
235
247
* Test file ID extractor to fine-tune Allure's history feature.
236
248
* @default ({ filePath }) => filePath.join('/')
@@ -331,6 +343,10 @@ declare module 'jest-allure2-reporter' {
331
343
export type ResolvedTestStepCustomizer = Required < TestStepCustomizer > ;
332
344
333
345
export interface TestStepCustomizer {
346
+ /**
347
+ * Extractor to omit test steps from the report.
348
+ */
349
+ hidden : TestStepExtractor < boolean > ;
334
350
/**
335
351
* Extractor for the step name.
336
352
* @example ({ value }) => value.replace(/(before|after)(Each|All)/, (_, p1, p2) => p1 + ' ' + p2.toLowerCase())
@@ -410,96 +426,145 @@ declare module 'jest-allure2-reporter' {
410
426
value : T | undefined ;
411
427
}
412
428
413
- export interface GlobalExtractorContext < T = unknown >
429
+ export interface GlobalExtractorContext < T = any >
414
430
extends ExtractorContext < T > ,
415
431
GlobalExtractorContextAugmentation {
416
432
globalConfig : Config . GlobalConfig ;
417
433
config : ReporterConfig ;
418
434
}
419
435
420
- export interface TestFileExtractorContext < T = unknown >
436
+ export interface TestFileExtractorContext < T = any >
421
437
extends GlobalExtractorContext < T > ,
422
438
TestFileExtractorContextAugmentation {
423
439
filePath : string [ ] ;
424
440
testFile : TestResult ;
425
- testFileMetadata : AllureTestCaseMetadata ;
441
+ testFileDocblock ?: DocblockContext ;
442
+ testFileMetadata : AllureTestFileMetadata ;
426
443
}
427
444
428
- export interface TestCaseExtractorContext < T = unknown >
445
+ export interface TestCaseExtractorContext < T = any >
429
446
extends TestFileExtractorContext < T > ,
430
447
TestCaseExtractorContextAugmentation {
431
448
testCase : TestCaseResult ;
449
+ testCaseDocblock ?: DocblockContext ;
432
450
testCaseMetadata : AllureTestCaseMetadata ;
433
451
}
434
452
435
- export interface TestStepExtractorContext < T = unknown >
453
+ export interface TestStepExtractorContext < T = any >
436
454
extends TestCaseExtractorContext < T > ,
437
455
TestStepExtractorContextAugmentation {
456
+ testStepDocblock ?: DocblockContext ;
438
457
testStepMetadata : AllureTestStepMetadata ;
439
458
}
440
459
441
- export interface AllureTestStepMetadata {
442
- steps ?: AllureTestStepMetadata [ ] ;
443
- hidden ?: boolean ;
460
+ export interface AllureTestItemSourceLocation {
461
+ fileName ?: string ;
462
+ lineNumber ?: number ;
463
+ columnNumber ?: number ;
464
+ }
465
+
466
+ export type AllureTestStepPath = string [ ] ;
467
+
468
+ export interface AllureTestItemMetadata {
444
469
/**
445
- * Source code of the test case, test step or a hook .
470
+ * File attachments to be added to the test case, test step or a test file .
446
471
*/
447
- code ?: string [ ] ;
448
-
449
- name ?: string ;
450
- status ?: Status ;
451
- statusDetails ?: StatusDetails ;
452
- stage ?: Stage ;
453
472
attachments ?: Attachment [ ] ;
473
+ /**
474
+ * Property path to the current step metadata object.
475
+ * @see {steps}
476
+ * @example ['steps', '0']
477
+ */
478
+ currentStep ?: AllureTestStepPath ;
479
+ /**
480
+ * Source code of the test case, test step or a hook.
481
+ */
482
+ sourceCode ?: string ;
483
+ /**
484
+ * Location (file, line, column) of the test case, test step or a hook.
485
+ */
486
+ sourceLocation ?: AllureTestItemSourceLocation ;
487
+ /**
488
+ * Markdown description of the test case or test file, or plain text description of a test step.
489
+ */
490
+ description ?: string [ ] ;
491
+ /**
492
+ * Key-value pairs to disambiguate test cases or to provide additional information.
493
+ */
454
494
parameters ?: Parameter [ ] ;
495
+ /**
496
+ * Indicates test item execution progress.
497
+ */
498
+ stage ?: Stage ;
499
+ /**
500
+ * Start timestamp in milliseconds.
501
+ */
455
502
start ?: number ;
456
- stop ?: number ;
457
- }
458
-
459
- export interface AllureTestCaseMetadata extends AllureTestStepMetadata {
460
503
/**
461
- * Pointer to the child step that is currently being added or executed.
462
- * @example ['steps', '0', 'steps', '0']
463
- * @internal
504
+ * Test result: failed, broken, passed, skipped or unknown.
464
505
*/
465
- currentStep ?: string [ ] ;
506
+ status ?: Status ;
466
507
/**
467
- * Jest worker ID.
468
- * @internal Used to generate unique thread names.
469
- * @see {import('@noomorph/allure-js-commons').LabelName.THREAD }
508
+ * Extra information about the test result: message and stack trace.
470
509
*/
471
- workerId ?: string ;
510
+ statusDetails ?: StatusDetails ;
472
511
/**
473
- * Only steps can have names .
512
+ * Recursive data structure to represent test steps for more granular reporting .
474
513
*/
475
- name ?: never ;
476
- description ?: string [ ] ;
514
+ steps ?: Omit < AllureTestStepMetadata , 'currentStep' > [ ] ;
515
+ /**
516
+ * Stop timestamp in milliseconds.
517
+ */
518
+ stop ?: number ;
519
+ }
520
+
521
+ export interface AllureTestStepMetadata extends AllureTestItemMetadata {
522
+ /**
523
+ * Steps produced by Jest hooks will have this property set.
524
+ * User-defined steps don't have this property.
525
+ */
526
+ hookType ?: 'beforeAll' | 'beforeEach' | 'afterEach' | 'afterAll' ;
527
+ }
528
+
529
+ export interface AllureTestCaseMetadata extends AllureTestItemMetadata {
477
530
descriptionHtml ?: string [ ] ;
478
531
labels ?: Label [ ] ;
479
532
links ?: Link [ ] ;
480
533
}
481
534
482
535
export interface AllureTestFileMetadata extends AllureTestCaseMetadata {
483
- currentStep ?: never ;
536
+ code ?: never ;
537
+ steps ?: never ;
538
+ workerId ?: string ;
539
+ }
540
+
541
+ export interface AllureGlobalMetadata {
542
+ config : Pick < ReporterConfig , 'resultsDir' | 'overwrite' | 'attachments' | 'injectGlobals' > ;
543
+ }
544
+
545
+ export interface DocblockContext {
546
+ comments : string ;
547
+ pragmas : Record < string , string [ ] > ;
548
+ raw : string ;
484
549
}
485
550
486
551
export interface GlobalExtractorContextAugmentation {
487
- detectLanguage ?( filePath : string , contents : string ) : string | undefined ;
552
+ detectLanguage ?( contents : string , filePath ? : string ) : string | undefined ;
488
553
processMarkdown ?( markdown : string ) : Promise < string > ;
489
554
490
- // This should be extended by plugins
555
+ // This may be extended by plugins
491
556
}
492
557
493
558
export interface TestFileExtractorContextAugmentation {
494
- // This should be extended by plugins
559
+ // This may be extended by plugins
495
560
}
496
561
497
562
export interface TestCaseExtractorContextAugmentation {
498
- // This should be extended by plugins
563
+ // This may be extended by plugins
499
564
}
500
565
501
566
export interface TestStepExtractorContextAugmentation {
502
- // This should be extended by plugins
567
+ // This may be extended by plugins
503
568
}
504
569
505
570
export type PluginDeclaration =
@@ -527,11 +592,6 @@ declare module 'jest-allure2-reporter' {
527
592
/** Method to extend global context. */
528
593
globalContext ?( context : GlobalExtractorContext ) : void | Promise < void > ;
529
594
530
- /** Method to affect test file metadata before it is created. */
531
- beforeTestFileContext ?(
532
- context : Omit < TestFileExtractorContext , 'testFileMetadata' > ,
533
- ) : void | Promise < void > ;
534
-
535
595
/** Method to extend test file context. */
536
596
testFileContext ?( context : TestFileExtractorContext ) : void | Promise < void > ;
537
597
@@ -544,7 +604,6 @@ declare module 'jest-allure2-reporter' {
544
604
545
605
export type PluginHookName =
546
606
| 'globalContext'
547
- | 'beforeTestFileContext'
548
607
| 'testFileContext'
549
608
| 'testCaseContext'
550
609
| 'testStepContext' ;
0 commit comments