@@ -11,63 +11,75 @@ import url from 'url';
1111
1212const matchCSS = ( doc , regexes ) => {
1313 if ( process . env . E2E_FILE ) {
14- const elements = doc . getElementsByTagName ( 'link' ) ;
15- let href = "" ;
16- for ( const elem of elements ) {
17- if ( elem . rel === 'stylesheet' ) {
18- href = elem . href ;
19- }
14+ const elements = doc . getElementsByTagName ( 'link' ) ;
15+ let href = '' ;
16+ for ( const elem of elements ) {
17+ if ( elem . rel === 'stylesheet' ) {
18+ href = elem . href ;
2019 }
21- resourceLoader (
22- { url : url . parse ( href ) } ,
23- ( _ , textContent ) => {
24- for ( const regex of regexes ) {
25- expect ( textContent ) . to . match ( regex ) ;
26- }
27- }
28- ) ;
29-
20+ }
21+ resourceLoader ( { url : url . parse ( href ) } , ( _ , textContent ) => {
22+ for ( const regex of regexes ) {
23+ expect ( textContent ) . to . match ( regex ) ;
24+ }
25+ } ) ;
3026 } else {
3127 for ( let i = 0 ; i < regexes . length ; ++ i ) {
32- expect ( doc . getElementsByTagName ( 'style' ) [ i ] . textContent . replace ( / \s / g, '' ) ) . to . match ( regexes [ i ] ) ;
28+ expect (
29+ doc . getElementsByTagName ( 'style' ) [ i ] . textContent . replace ( / \s / g, '' )
30+ ) . to . match ( regexes [ i ] ) ;
3331 }
3432 }
35- }
33+ } ;
3634
3735describe ( 'Integration' , ( ) => {
3836 describe ( 'Webpack plugins' , ( ) => {
3937 it ( 'css inclusion' , async ( ) => {
4038 const doc = await initDOM ( 'css-inclusion' ) ;
41- matchCSS ( doc , [ / h t m l \{ / , / # f e a t u r e - c s s - i n c l u s i o n \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ] ) ;
39+ matchCSS ( doc , [
40+ / h t m l \{ / ,
41+ / # f e a t u r e - c s s - i n c l u s i o n \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
42+ ] ) ;
43+ doc . defaultView . close ( ) ;
4244 } ) ;
4345
4446 it ( 'css modules inclusion' , async ( ) => {
4547 const doc = await initDOM ( 'css-modules-inclusion' ) ;
46- matchCSS ( doc , [ / .+ s t y l e _ c s s M o d u l e s I n c l u s i o n _ _ .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
47- / .+ a s s e t s _ c s s M o d u l e s I n d e x I n c l u s i o n _ _ .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ] ) ;
48+ matchCSS ( doc , [
49+ / .+ s t y l e _ c s s M o d u l e s I n c l u s i o n _ _ .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
50+ / .+ a s s e t s _ c s s M o d u l e s I n d e x I n c l u s i o n _ _ .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
51+ ] ) ;
52+ doc . defaultView . close ( ) ;
4853 } ) ;
4954
5055 it ( 'scss inclusion' , async ( ) => {
5156 const doc = await initDOM ( 'scss-inclusion' ) ;
5257 matchCSS ( doc , [ / # f e a t u r e - s c s s - i n c l u s i o n \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ] ) ;
58+ doc . defaultView . close ( ) ;
5359 } ) ;
5460
5561 it ( 'scss modules inclusion' , async ( ) => {
5662 const doc = await initDOM ( 'scss-modules-inclusion' ) ;
57- matchCSS ( doc , [ / .+ s c s s - s t y l e s _ s c s s M o d u l e s I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
58- / .+ a s s e t s _ s c s s M o d u l e s I n d e x I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ] ) ;
59-
63+ matchCSS ( doc , [
64+ / .+ s c s s - s t y l e s _ s c s s M o d u l e s I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
65+ / .+ a s s e t s _ s c s s M o d u l e s I n d e x I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
66+ ] ) ;
67+ doc . defaultView . close ( ) ;
6068 } ) ;
6169
6270 it ( 'sass inclusion' , async ( ) => {
6371 const doc = await initDOM ( 'sass-inclusion' ) ;
6472 matchCSS ( doc , [ / # f e a t u r e - s a s s - i n c l u s i o n \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ] ) ;
73+ doc . defaultView . close ( ) ;
6574 } ) ;
6675
6776 it ( 'sass modules inclusion' , async ( ) => {
6877 const doc = await initDOM ( 'sass-modules-inclusion' ) ;
69- matchCSS ( doc , [ / .+ s a s s - s t y l e s _ s a s s M o d u l e s I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
70- / .+ a s s e t s _ s a s s M o d u l e s I n d e x I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ] ) ;
78+ matchCSS ( doc , [
79+ / .+ s a s s - s t y l e s _ s a s s M o d u l e s I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
80+ / .+ a s s e t s _ s a s s M o d u l e s I n d e x I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
81+ ] ) ;
82+ doc . defaultView . close ( ) ;
7183 } ) ;
7284
7385 it ( 'graphql files inclusion' , async ( ) => {
@@ -78,6 +90,7 @@ describe('Integration', () => {
7890 expect ( children [ 0 ] . textContent . replace ( / \s / g, '' ) ) . to . equal (
7991 '{"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","variableDefinitions":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"test"},"value":{"kind":"StringValue","value":"test","block":false}}],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[],"directives":[]}]}}]}}],"loc":{"start":0,"end":40,"source":{"body":"{\\ntest(test:\\"test\\"){\\ntest\\n}\\n}\\n","name":"GraphQLrequest","locationOffset":{"line":1,"column":1}}}}'
8092 ) ;
93+ doc . defaultView . close ( ) ;
8194 } ) ;
8295
8396 it ( 'image inclusion' , async ( ) => {
@@ -86,6 +99,7 @@ describe('Integration', () => {
8699 expect ( doc . getElementById ( 'feature-image-inclusion' ) . src ) . to . match (
87100 / ^ d a t a : i m a g e \/ j p e g ; b a s e 6 4 .+ = = $ /
88101 ) ;
102+ doc . defaultView . close ( ) ;
89103 } ) ;
90104
91105 it ( 'no ext inclusion' , async ( ) => {
@@ -94,6 +108,7 @@ describe('Integration', () => {
94108 expect ( doc . getElementById ( 'feature-no-ext-inclusion' ) . href ) . to . match (
95109 / \/ s t a t i c \/ m e d i a \/ a F i l e W i t h o u t E x t \. [ a - f 0 - 9 ] { 8 } \. b i n $ /
96110 ) ;
111+ doc . defaultView . close ( ) ;
97112 } ) ;
98113
99114 it ( 'json inclusion' , async ( ) => {
@@ -102,6 +117,7 @@ describe('Integration', () => {
102117 expect ( doc . getElementById ( 'feature-json-inclusion' ) . textContent ) . to . equal (
103118 'This is an abstract.'
104119 ) ;
120+ doc . defaultView . close ( ) ;
105121 } ) ;
106122
107123 it ( 'linked modules' , async ( ) => {
@@ -110,13 +126,15 @@ describe('Integration', () => {
110126 expect ( doc . getElementById ( 'feature-linked-modules' ) . textContent ) . to . equal (
111127 '2.0.0'
112128 ) ;
129+ doc . defaultView . close ( ) ;
113130 } ) ;
114131
115132 it ( 'svg inclusion' , async ( ) => {
116133 const doc = await initDOM ( 'svg-inclusion' ) ;
117134 expect ( doc . getElementById ( 'feature-svg-inclusion' ) . src ) . to . match (
118135 / \/ s t a t i c \/ m e d i a \/ l o g o \. .+ \. s v g $ /
119136 ) ;
137+ doc . defaultView . close ( ) ;
120138 } ) ;
121139
122140 it ( 'svg component' , async ( ) => {
@@ -125,11 +143,13 @@ describe('Integration', () => {
125143 expect ( doc . getElementById ( 'feature-svg-component' ) . textContent ) . to . equal (
126144 ''
127145 ) ;
146+ doc . defaultView . close ( ) ;
128147 } ) ;
129148
130149 it ( 'svg in css' , async ( ) => {
131150 const doc = await initDOM ( 'svg-in-css' ) ;
132151 matchCSS ( doc , [ / \/ s t a t i c \/ m e d i a \/ l o g o \. .+ \. s v g / ] ) ;
152+ doc . defaultView . close ( ) ;
133153 } ) ;
134154
135155 it ( 'unknown ext inclusion' , async ( ) => {
@@ -138,6 +158,7 @@ describe('Integration', () => {
138158 expect ( doc . getElementById ( 'feature-unknown-ext-inclusion' ) . href ) . to . match (
139159 / \/ s t a t i c \/ m e d i a \/ a F i l e W i t h E x t \. [ a - f 0 - 9 ] { 8 } \. u n k n o w n $ /
140160 ) ;
161+ doc . defaultView . close ( ) ;
141162 } ) ;
142163 } ) ;
143164} ) ;
0 commit comments