Skip to content

Commit db48eff

Browse files
committed
test: further normalize server port snapshots
Follow-up to #7203
1 parent e7cd9e5 commit db48eff

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

Diff for: tests/integration/__snapshots__/framework-detection.test.js.snap

+20-20
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ exports[`frameworks/framework-detection > should default to process.cwd() and st
1111
1212
◈ Static server listening to <SNAPSHOT_PORT_NORMALIZED>
1313
14-
┌──────────────────────────────────────────────────┐
15-
│ │
14+
┌───────────────────────────────────────────────────────────────────────
15+
1616
│ ◈ Server now ready on http://localhost:<SNAPSHOT_PORT_NORMALIZED> │
17-
│ │
18-
└──────────────────────────────────────────────────┘"
17+
18+
└───────────────────────────────────────────────────────────────────────┘"
1919
`;
2020
2121
exports[`frameworks/framework-detection > should detect a known framework 1`] = `
@@ -40,11 +40,11 @@ exports[`frameworks/framework-detection > should filter frameworks with no dev c
4040
4141
◈ Static server listening to <SNAPSHOT_PORT_NORMALIZED>
4242
43-
┌──────────────────────────────────────────────────┐
44-
│ │
43+
┌───────────────────────────────────────────────────────────────────────
44+
4545
│ ◈ Server now ready on http://localhost:<SNAPSHOT_PORT_NORMALIZED> │
46-
│ │
47-
└──────────────────────────────────────────────────┘"
46+
47+
└───────────────────────────────────────────────────────────────────────┘"
4848
`;
4949
5050
exports[`frameworks/framework-detection > should force a specific framework when configured 1`] = `
@@ -152,11 +152,11 @@ exports[`frameworks/framework-detection > should use static server when --dir fl
152152
153153
◈ Static server listening to <SNAPSHOT_PORT_NORMALIZED>
154154
155-
┌──────────────────────────────────────────────────┐
156-
│ │
155+
┌───────────────────────────────────────────────────────────────────────
156+
157157
│ ◈ Server now ready on http://localhost:<SNAPSHOT_PORT_NORMALIZED> │
158-
│ │
159-
└──────────────────────────────────────────────────┘"
158+
159+
└───────────────────────────────────────────────────────────────────────┘"
160160
`;
161161
162162
exports[`frameworks/framework-detection > should use static server when framework is set to #static 1`] = `
@@ -170,11 +170,11 @@ exports[`frameworks/framework-detection > should use static server when framewor
170170
171171
◈ Static server listening to <SNAPSHOT_PORT_NORMALIZED>
172172
173-
┌──────────────────────────────────────────────────┐
174-
│ │
173+
┌───────────────────────────────────────────────────────────────────────
174+
175175
│ ◈ Server now ready on http://localhost:<SNAPSHOT_PORT_NORMALIZED> │
176-
│ │
177-
└──────────────────────────────────────────────────┘"
176+
177+
└───────────────────────────────────────────────────────────────────────┘"
178178
`;
179179
180180
exports[`frameworks/framework-detection > should warn if using static server and \`targetPort\` is configured 1`] = `
@@ -187,9 +187,9 @@ exports[`frameworks/framework-detection > should warn if using static server and
187187
188188
◈ Static server listening to <SNAPSHOT_PORT_NORMALIZED>
189189
190-
┌──────────────────────────────────────────────────┐
191-
│ │
190+
┌───────────────────────────────────────────────────────────────────────
191+
192192
│ ◈ Server now ready on http://localhost:<SNAPSHOT_PORT_NORMALIZED> │
193-
│ │
194-
└──────────────────────────────────────────────────┘"
193+
194+
└───────────────────────────────────────────────────────────────────────┘"
195195
`;

Diff for: tests/integration/framework-detection.test.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ import { normalize } from './utils/snapshots.js'
1010

1111
const content = 'Hello World!'
1212

13-
// Normalize random ports
13+
// Normalize random ports. Not only are these ports random, but since the number of digits
14+
// in the port can vary, the formatting of the ASCII box drawn around it also varies.
1415
const normalizeSnapshot = (output, opts) =>
15-
normalize(output, opts)
16-
.replaceAll(/localhost:\d+/g, 'localhost:<SNAPSHOT_PORT_NORMALIZED>')
17-
.replaceAll(/listening to \d+/g, 'listening to <SNAPSHOT_PORT_NORMALIZED>')
16+
normalize(output, opts).replace(
17+
/ Static server listening to \d+[\s]+ Server now ready on http:\/\/localhost:\d+ [\s]+/m,
18+
`◈ Static server listening to <SNAPSHOT_PORT_NORMALIZED>
19+
20+
┌───────────────────────────────────────────────────────────────────────┐
21+
│ │
22+
│ ◈ Server now ready on http://localhost:<SNAPSHOT_PORT_NORMALIZED> │
23+
│ │
24+
└───────────────────────────────────────────────────────────────────────┘`,
25+
)
1826

1927
describe.concurrent('frameworks/framework-detection', () => {
2028
test('should default to process.cwd() and static server', async (t) => {

0 commit comments

Comments
 (0)