@@ -10,6 +10,12 @@ import { normalize } from './utils/snapshots.js'
10
10
11
11
const content = 'Hello World!'
12
12
13
+ // Normalize random ports
14
+ const normalizeSnapshot = ( output , opts ) =>
15
+ normalize ( output , opts )
16
+ . replaceAll ( / l o c a l h o s t : \d + / g, 'localhost:<SNAPSHOT_PORT_NORMALIZED>' )
17
+ . replaceAll ( / l i s t e n i n g t o \d + / g, 'listening to <SNAPSHOT_PORT_NORMALIZED>' )
18
+
13
19
describe . concurrent ( 'frameworks/framework-detection' , ( ) => {
14
20
test ( 'should default to process.cwd() and static server' , async ( t ) => {
15
21
await withSiteBuilder ( t , async ( builder ) => {
@@ -25,7 +31,7 @@ describe.concurrent('frameworks/framework-detection', () => {
25
31
const responseContent = await response . text ( )
26
32
27
33
t . expect ( responseContent ) . toEqual ( content )
28
- t . expect ( normalize ( output , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
34
+ t . expect ( normalizeSnapshot ( output , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
29
35
} )
30
36
} )
31
37
} )
@@ -44,7 +50,7 @@ describe.concurrent('frameworks/framework-detection', () => {
44
50
const responseContent = await response . text ( )
45
51
46
52
t . expect ( responseContent ) . toEqual ( content )
47
- t . expect ( normalize ( output , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
53
+ t . expect ( normalizeSnapshot ( output , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
48
54
} )
49
55
} )
50
56
} )
@@ -64,7 +70,7 @@ describe.concurrent('frameworks/framework-detection', () => {
64
70
const responseContent = await response . text ( )
65
71
66
72
t . expect ( responseContent ) . toEqual ( content )
67
- t . expect ( normalize ( output , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
73
+ t . expect ( normalizeSnapshot ( output , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
68
74
} )
69
75
} )
70
76
} )
@@ -85,7 +91,7 @@ describe.concurrent('frameworks/framework-detection', () => {
85
91
const responseContent = await response . text ( )
86
92
87
93
t . expect ( responseContent ) . toEqual ( content )
88
- t . expect ( normalize ( output , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
94
+ t . expect ( normalizeSnapshot ( output , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
89
95
} ,
90
96
)
91
97
} )
@@ -102,7 +108,7 @@ describe.concurrent('frameworks/framework-detection', () => {
102
108
true ,
103
109
) . catch ( ( error_ ) => error_ )
104
110
105
- t . expect ( normalize ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
111
+ t . expect ( normalizeSnapshot ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
106
112
} )
107
113
} )
108
114
@@ -112,7 +118,7 @@ describe.concurrent('frameworks/framework-detection', () => {
112
118
113
119
// a failure is expected since this is not a true create-react-app project
114
120
const error = await withDevServer ( { cwd : builder . directory } , ( ) => { } , true ) . catch ( ( error_ ) => error_ )
115
- t . expect ( normalize ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
121
+ t . expect ( normalizeSnapshot ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
116
122
} )
117
123
} )
118
124
@@ -121,7 +127,7 @@ describe.concurrent('frameworks/framework-detection', () => {
121
127
await builder . withNetlifyToml ( { config : { dev : { framework : 'to-infinity-and-beyond-js' } } } ) . build ( )
122
128
123
129
const error = await withDevServer ( { cwd : builder . directory } , ( ) => { } , true ) . catch ( ( error_ ) => error_ )
124
- t . expect ( normalize ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
130
+ t . expect ( normalizeSnapshot ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
125
131
} )
126
132
} )
127
133
@@ -135,7 +141,7 @@ describe.concurrent('frameworks/framework-detection', () => {
135
141
136
142
// a failure is expected since this is not a true create-react-app project
137
143
const error = await withDevServer ( { cwd : builder . directory } , ( ) => { } , true ) . catch ( ( error_ ) => error_ )
138
- t . expect ( normalize ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
144
+ t . expect ( normalizeSnapshot ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
139
145
} )
140
146
} )
141
147
@@ -148,7 +154,7 @@ describe.concurrent('frameworks/framework-detection', () => {
148
154
( ) => { } ,
149
155
true ,
150
156
) . catch ( ( error_ ) => error_ )
151
- t . expect ( normalize ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
157
+ t . expect ( normalizeSnapshot ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
152
158
} )
153
159
} )
154
160
@@ -161,7 +167,7 @@ describe.concurrent('frameworks/framework-detection', () => {
161
167
( ) => { } ,
162
168
true ,
163
169
) . catch ( ( error_ ) => error_ )
164
- t . expect ( normalize ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
170
+ t . expect ( normalizeSnapshot ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
165
171
} )
166
172
} )
167
173
@@ -174,7 +180,7 @@ describe.concurrent('frameworks/framework-detection', () => {
174
180
( ) => { } ,
175
181
true ,
176
182
) . catch ( ( error_ ) => error_ )
177
- t . expect ( normalize ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
183
+ t . expect ( normalizeSnapshot ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
178
184
} )
179
185
} )
180
186
@@ -198,7 +204,7 @@ describe.concurrent('frameworks/framework-detection', () => {
198
204
true ,
199
205
) . catch ( ( error_ ) => error_ )
200
206
201
- t . expect ( normalize ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
207
+ t . expect ( normalizeSnapshot ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
202
208
} )
203
209
} )
204
210
@@ -232,7 +238,7 @@ describe.concurrent('frameworks/framework-detection', () => {
232
238
await childProcess
233
239
}
234
240
const error = await asyncErrorBlock ( ) . catch ( ( error_ ) => error_ )
235
- t . expect ( normalize ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
241
+ t . expect ( normalizeSnapshot ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
236
242
} )
237
243
} )
238
244
@@ -259,7 +265,7 @@ describe.concurrent('frameworks/framework-detection', () => {
259
265
}
260
266
const error = await asyncErrorBlock ( ) . catch ( ( error_ ) => error_ )
261
267
t . expect (
262
- normalize ( error . stdout , { duration : true , filePath : true } ) . includes (
268
+ normalizeSnapshot ( error . stdout , { duration : true , filePath : true } ) . includes (
263
269
'Detected commands for: Gatsby, Create React App. Update your settings to specify which to use. Refer to https://ntl.fyi/dev-monorepo for more information.' ,
264
270
) ,
265
271
)
@@ -278,7 +284,7 @@ describe.concurrent('frameworks/framework-detection', () => {
278
284
true ,
279
285
) . catch ( ( error_ ) => error_ )
280
286
281
- t . expect ( normalize ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
287
+ t . expect ( normalizeSnapshot ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
282
288
} )
283
289
} )
284
290
@@ -299,7 +305,7 @@ describe.concurrent('frameworks/framework-detection', () => {
299
305
const responseContent = await response . text ( )
300
306
301
307
t . expect ( responseContent ) . toEqual ( content )
302
- t . expect ( normalize ( output , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
308
+ t . expect ( normalizeSnapshot ( output , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
303
309
} )
304
310
} )
305
311
} )
@@ -317,7 +323,7 @@ describe.concurrent('frameworks/framework-detection', () => {
317
323
318
324
// a failure is expected since this is not a true Gatsby project
319
325
const error = await withDevServer ( { cwd : builder . directory } , ( ) => { } , true ) . catch ( ( error_ ) => error_ )
320
- t . expect ( normalize ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
326
+ t . expect ( normalizeSnapshot ( error . stdout , { duration : true , filePath : true } ) ) . toMatchSnapshot ( )
321
327
} )
322
328
} )
323
329
@@ -395,7 +401,7 @@ describe.concurrent('frameworks/framework-detection', () => {
395
401
const responseJson = await response . json ( )
396
402
t . expect ( responseJson ) . toStrictEqual ( { CONTEXT_CHECK : 'PRODUCTION' } )
397
403
398
- const normalizedText = normalize ( output , { duration : true , filePath : true } )
404
+ const normalizedText = normalizeSnapshot ( output , { duration : true , filePath : true } )
399
405
t . expect (
400
406
normalizedText . includes (
401
407
`Changes will not be hot-reloaded, so if you need to rebuild your site you must exit and run 'netlify serve' again` ,
0 commit comments