@@ -3,18 +3,26 @@ import { getParentsArray, parseAllure } from 'allure-js-parser';
3
3
import { extname } from '../../../../src/common' ;
4
4
import { readFileSync } from 'fs' ;
5
5
6
+ // issue https://github.com/mmisty/cypress-allure-adapter/issues/95
6
7
describe ( 'several nested suites with global hook - hook should be added to all children' , ( ) => {
7
8
const res = createResTest2 ( [
8
9
`
10
+ before('glob hook', () => {
11
+ cy.log('before');
12
+ });
13
+
9
14
describe('hello suite', () => {
10
15
before('parent hook', () => {
11
- cy.allure().attachment('out parent ', 'test number', 'text/plain');
16
+ cy.allure().attachment('out', 'test number', 'text/plain');
12
17
cy.log('before');
13
18
});
14
19
20
+ it('test 1', () => {
21
+ cy.log('message');
22
+ });
23
+
15
24
describe('child suite', () => {
16
25
before('child hook', () => {
17
- cy.allure().attachment('out child', 'test number', 'text/plain');
18
26
cy.log('before');
19
27
});
20
28
@@ -37,47 +45,56 @@ describe('hello suite', () => {
37
45
} ) ;
38
46
39
47
it ( 'check tests count' , async ( ) => {
40
- expect ( resFixed . length ) . toEqual ( 1 ) ;
48
+ expect ( resFixed . length ) . toEqual ( 2 ) ;
41
49
} ) ;
42
50
43
51
it ( 'check tests names' , async ( ) => {
44
52
expect ( resFixed . map ( t => t . fullName ) . sort ( ) ) . toEqual ( [
45
53
'hello suite child suite sub sub suite hello test' ,
54
+ 'hello suite test 1' ,
46
55
] ) ;
47
56
} ) ;
48
57
49
58
it ( 'suites parents' , ( ) => {
50
59
expect (
51
- resFixed . map ( t => ( {
52
- name : t . name ,
53
- status : t . status ,
54
- parents : getParentsArray ( t ) . map ( t => ( {
60
+ resFixed
61
+ . sort ( ( a , b ) => ( a . name < b . name ? - 1 : 1 ) )
62
+ . map ( t => ( {
55
63
name : t . name ,
56
- befores : t . befores
57
- ?. filter ( x => ( x as any ) . name !== '"before all" hook' )
58
- . map ( x => ( {
59
- name : ( x as any ) . name ,
60
- status : x . status ,
61
- attachments : x . attachments . map ( t => ( {
62
- ...t ,
63
- source : `source${ extname ( t . source ) } ` ,
64
- sourceContentMoreThanZero :
65
- readFileSync ( `${ res . watch } /${ t . source } ` ) . toString ( ) . length >
66
- 0 ,
64
+ status : t . status ,
65
+ parents : getParentsArray ( t ) . map ( t => ( {
66
+ name : t . name ,
67
+ befores : t . befores
68
+ ?. filter ( x => ( x as any ) . name !== '"before all" hook' )
69
+ . map ( x => ( {
70
+ name : ( x as any ) . name ,
71
+ status : x . status ,
72
+ statusDetails : x . statusDetails ,
73
+ attachments : x . attachments . map ( t => ( {
74
+ ...t ,
75
+ source : `source${ extname ( t . source ) } ` ,
76
+ sourceContentMoreThanZero :
77
+ readFileSync ( `${ res . watch } /${ t . source } ` ) . toString ( )
78
+ . length > 0 ,
79
+ } ) ) ,
67
80
} ) ) ,
68
- } ) ) ,
81
+ } ) ) ,
69
82
} ) ) ,
70
- } ) ) ,
71
83
) . toEqual ( [
72
84
{
73
85
name : 'hello test' ,
74
86
parents : [
75
87
{
76
88
befores : [
89
+ {
90
+ name : '"before all" hook: glob hook' ,
91
+ status : 'passed' ,
92
+ attachments : [ ] ,
93
+ } ,
77
94
{
78
95
attachments : [
79
96
{
80
- name : 'out parent ' ,
97
+ name : 'out' ,
81
98
source : 'source.txt' ,
82
99
sourceContentMoreThanZero : true ,
83
100
type : 'text/plain' ,
@@ -87,14 +104,7 @@ describe('hello suite', () => {
87
104
status : 'passed' ,
88
105
} ,
89
106
{
90
- attachments : [
91
- {
92
- name : 'out child' ,
93
- source : 'source.txt' ,
94
- sourceContentMoreThanZero : true ,
95
- type : 'text/plain' ,
96
- } ,
97
- ] ,
107
+ attachments : [ ] ,
98
108
name : '"before all" hook: child hook' ,
99
109
status : 'passed' ,
100
110
} ,
@@ -103,39 +113,75 @@ describe('hello suite', () => {
103
113
} ,
104
114
{
105
115
befores : [
116
+ {
117
+ attachments : [ ] ,
118
+ name : '"before all" hook: glob hook' ,
119
+ status : 'passed' ,
120
+ statusDetails : { } ,
121
+ } ,
106
122
{
107
123
attachments : [
108
124
{
109
- name : 'out parent ' ,
125
+ name : 'out' ,
110
126
source : 'source.txt' ,
111
127
sourceContentMoreThanZero : true ,
112
128
type : 'text/plain' ,
113
129
} ,
114
130
] ,
115
131
name : '"before all" hook: parent hook' ,
116
132
status : 'passed' ,
133
+ statusDetails : { } ,
134
+ } ,
135
+ {
136
+ attachments : [ ] ,
137
+ name : '"before all" hook: child hook' ,
138
+ status : 'passed' ,
139
+ statusDetails : { } ,
140
+ } ,
141
+ ] ,
142
+ name : 'child suite' ,
143
+ } ,
144
+ {
145
+ befores : [
146
+ {
147
+ attachments : [ ] ,
148
+ name : '"before all" hook: glob hook' ,
149
+ status : 'passed' ,
150
+ statusDetails : { } ,
117
151
} ,
118
152
{
119
153
attachments : [
120
154
{
121
- name : 'out child ' ,
155
+ name : 'out' ,
122
156
source : 'source.txt' ,
123
157
sourceContentMoreThanZero : true ,
124
158
type : 'text/plain' ,
125
159
} ,
126
160
] ,
127
- name : '"before all" hook: child hook' ,
161
+ name : '"before all" hook: parent hook' ,
128
162
status : 'passed' ,
163
+ statusDetails : { } ,
129
164
} ,
130
165
] ,
131
- name : 'child suite' ,
166
+ name : 'hello suite' ,
132
167
} ,
168
+ ] ,
169
+ status : 'passed' ,
170
+ } ,
171
+ {
172
+ name : 'test 1' ,
173
+ parents : [
133
174
{
134
175
befores : [
176
+ {
177
+ attachments : [ ] ,
178
+ name : '"before all" hook: glob hook' ,
179
+ status : 'passed' ,
180
+ } ,
135
181
{
136
182
attachments : [
137
183
{
138
- name : 'out parent ' ,
184
+ name : 'out' ,
139
185
source : 'source.txt' ,
140
186
sourceContentMoreThanZero : true ,
141
187
type : 'text/plain' ,
0 commit comments