Skip to content

test: further normalize server port snapshots #7206

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions tests/integration/__snapshots__/framework-detection.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ exports[`frameworks/framework-detection > should default to process.cwd() and st

◈ Static server listening to <SNAPSHOT_PORT_NORMALIZED>

┌──────────────────────────────────────────────────┐
│ │
┌───────────────────────────────────────────────────────────────────────
│ ◈ Server now ready on http://localhost:<SNAPSHOT_PORT_NORMALIZED> │
│ │
└──────────────────────────────────────────────────┘"
└───────────────────────────────────────────────────────────────────────┘"
`;

exports[`frameworks/framework-detection > should detect a known framework 1`] = `
Expand All @@ -40,11 +40,11 @@ exports[`frameworks/framework-detection > should filter frameworks with no dev c

◈ Static server listening to <SNAPSHOT_PORT_NORMALIZED>

┌──────────────────────────────────────────────────┐
│ │
┌───────────────────────────────────────────────────────────────────────
│ ◈ Server now ready on http://localhost:<SNAPSHOT_PORT_NORMALIZED> │
│ │
└──────────────────────────────────────────────────┘"
└───────────────────────────────────────────────────────────────────────┘"
`;

exports[`frameworks/framework-detection > should force a specific framework when configured 1`] = `
Expand Down Expand Up @@ -152,11 +152,11 @@ exports[`frameworks/framework-detection > should use static server when --dir fl

◈ Static server listening to <SNAPSHOT_PORT_NORMALIZED>

┌──────────────────────────────────────────────────┐
│ │
┌───────────────────────────────────────────────────────────────────────
│ ◈ Server now ready on http://localhost:<SNAPSHOT_PORT_NORMALIZED> │
│ │
└──────────────────────────────────────────────────┘"
└───────────────────────────────────────────────────────────────────────┘"
`;

exports[`frameworks/framework-detection > should use static server when framework is set to #static 1`] = `
Expand All @@ -170,11 +170,11 @@ exports[`frameworks/framework-detection > should use static server when framewor

◈ Static server listening to <SNAPSHOT_PORT_NORMALIZED>

┌──────────────────────────────────────────────────┐
│ │
┌───────────────────────────────────────────────────────────────────────
│ ◈ Server now ready on http://localhost:<SNAPSHOT_PORT_NORMALIZED> │
│ │
└──────────────────────────────────────────────────┘"
└───────────────────────────────────────────────────────────────────────┘"
`;

exports[`frameworks/framework-detection > should warn if using static server and \`targetPort\` is configured 1`] = `
Expand All @@ -187,9 +187,9 @@ exports[`frameworks/framework-detection > should warn if using static server and

◈ Static server listening to <SNAPSHOT_PORT_NORMALIZED>

┌──────────────────────────────────────────────────┐
│ │
┌───────────────────────────────────────────────────────────────────────
│ ◈ Server now ready on http://localhost:<SNAPSHOT_PORT_NORMALIZED> │
│ │
└──────────────────────────────────────────────────┘"
└───────────────────────────────────────────────────────────────────────┘"
`;
16 changes: 12 additions & 4 deletions tests/integration/framework-detection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ import { normalize } from './utils/snapshots.js'

const content = 'Hello World!'

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

┌───────────────────────────────────────────────────────────────────────┐
│ │
│ ◈ Server now ready on http://localhost:<SNAPSHOT_PORT_NORMALIZED> │
│ │
└───────────────────────────────────────────────────────────────────────┘`,
)

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