File tree 3 files changed +50
-5
lines changed
3 files changed +50
-5
lines changed Original file line number Diff line number Diff line change @@ -433,6 +433,16 @@ export default class SauceReporter implements Reporter {
433
433
434
434
const lines = getLines ( testCase ) ;
435
435
436
+ const metadata : Record < string , unknown > = { } ;
437
+ if ( testCase . id ) {
438
+ metadata . id = testCase . id ;
439
+ }
440
+ if ( testCase . tags . length > 0 ) {
441
+ metadata . tags = testCase . tags ;
442
+ }
443
+ if ( testCase . annotations . length > 0 ) {
444
+ metadata . annotations = testCase . annotations ;
445
+ }
436
446
const isSkipped = testCase . outcome ( ) === 'skipped' ;
437
447
const test = suite . withTest ( testCase . title , {
438
448
status : isSkipped
@@ -446,12 +456,8 @@ export default class SauceReporter implements Reporter {
446
456
: undefined ,
447
457
startTime : lastResult . startTime ,
448
458
code : new TestCode ( lines ) ,
459
+ metadata,
449
460
} ) ;
450
- if ( testCase . id ) {
451
- test . metadata = {
452
- id : testCase . id ,
453
- } ;
454
- }
455
461
456
462
for ( const attachment of lastResult . attachments ) {
457
463
if ( ! attachment . path && ! attachment . body ) {
Original file line number Diff line number Diff line change @@ -34,6 +34,10 @@ const config: PlaywrightTestConfig = {
34
34
name : 'Failing Suites' ,
35
35
testMatch : 'tests/failing.test.js' ,
36
36
} ,
37
+ {
38
+ name : 'Annotation tests' ,
39
+ testMatch : 'tests/annotation.test.ts' ,
40
+ } ,
37
41
] ,
38
42
} ;
39
43
Original file line number Diff line number Diff line change
1
+ import { test , expect } from '@playwright/test' ;
2
+
3
+ test ( '@implicit tag in title' , async ( { page } ) => {
4
+ await page . goto ( 'https://www.saucedemo.com/' ) ;
5
+
6
+ expect ( await page . title ( ) ) . toBe ( 'Swag Labs' ) ;
7
+ } ) ;
8
+
9
+ test ( 'explicit tag argument' , { tag : '@explicit' } , async ( { page } ) => {
10
+ await page . goto ( 'https://www.saucedemo.com/' ) ;
11
+
12
+ expect ( await page . title ( ) ) . toBe ( 'Swag Labs' ) ;
13
+ } ) ;
14
+
15
+ test ( 'built in annotation' , async ( { page } ) => {
16
+ test . slow ( ) ;
17
+
18
+ await page . goto ( 'https://www.saucedemo.com/' ) ;
19
+
20
+ expect ( await page . title ( ) ) . toBe ( 'Swag Labs' ) ;
21
+ } ) ;
22
+
23
+ test (
24
+ 'annotations' ,
25
+ { annotation : { type : 'static annotation' } } ,
26
+ async ( { page } ) => {
27
+ test . info ( ) . annotations . push ( {
28
+ type : 'runtime annotation' ,
29
+ description : 'annotation added during test execution' ,
30
+ } ) ;
31
+ await page . goto ( 'https://www.saucedemo.com/' ) ;
32
+
33
+ expect ( await page . title ( ) ) . toBe ( 'Swag Labs' ) ;
34
+ } ,
35
+ ) ;
You can’t perform that action at this time.
0 commit comments