Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
a49c479a
Commit
a49c479a
authored
Aug 22, 2025
by
RobPruzan
Committed by
Jiachi Liu
Sep 10, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't log browser console in terminal during test mode
parent
c8ee24d8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
6 deletions
+28
-6
forward-logs.test.ts
...next/src/next-devtools/userspace/app/forward-logs.test.ts
+1
-1
forward-logs.ts
...ages/next/src/next-devtools/userspace/app/forward-logs.ts
+1
-1
receive-logs.ts
packages/next/src/server/dev/browser-logs/receive-logs.ts
+11
-4
browser-logs.test.ts
test/development/browser-logs/browser-logs.test.ts
+15
-0
No files found.
packages/next/src/next-devtools/userspace/app/forward-logs.test.ts
View file @
a49c479a
import
{
UNDEFINED_MARKER
}
from
'../../shared/
forward-logs-shared
'
import
{
UNDEFINED_MARKER
}
from
'../../shared/
log-patch
'
import
{
import
{
preLogSerializationClone
,
preLogSerializationClone
,
PROMISE_MARKER
,
PROMISE_MARKER
,
...
...
packages/next/src/next-devtools/userspace/app/forward-logs.ts
View file @
a49c479a
...
@@ -16,7 +16,7 @@ import {
...
@@ -16,7 +16,7 @@ import {
type
LogMethod
,
type
LogMethod
,
patchConsoleMethod
,
patchConsoleMethod
,
UNDEFINED_MARKER
,
UNDEFINED_MARKER
,
}
from
'../../shared/
forward-logs-shared
'
}
from
'../../shared/
log-patch
'
const
terminalLoggingConfig
=
getTerminalLoggingConfig
()
const
terminalLoggingConfig
=
getTerminalLoggingConfig
()
export
const
PROMISE_MARKER
=
'Promise {}'
export
const
PROMISE_MARKER
=
'Promise {}'
...
...
packages/next/src/server/dev/browser-logs/receive-logs.ts
View file @
a49c479a
...
@@ -12,7 +12,7 @@ import {
...
@@ -12,7 +12,7 @@ import {
type
LogMethod
,
type
LogMethod
,
type
ConsoleEntry
,
type
ConsoleEntry
,
UNDEFINED_MARKER
,
UNDEFINED_MARKER
,
}
from
'../../../next-devtools/shared/
forward-logs-shared
'
}
from
'../../../next-devtools/shared/
log-patch
'
import
type
{
NextConfigComplete
}
from
'../../config-shared'
import
type
{
NextConfigComplete
}
from
'../../config-shared'
export
function
getDisplayedSourceLocation
(
export
function
getDisplayedSourceLocation
(
...
@@ -68,8 +68,14 @@ const forwardConsole: typeof console = {
...
@@ -68,8 +68,14 @@ const forwardConsole: typeof console = {
...
Object
.
fromEntries
(
...
Object
.
fromEntries
(
methods
.
map
((
method
)
=>
[
methods
.
map
((
method
)
=>
[
method
,
method
,
(...
args
:
Array
<
any
>
)
=>
(...
args
:
Array
<
any
>
)
=>
{
(
console
[
method
]
as
any
)(
if
(
process
.
env
.
__NEXT_TEST_MODE
&&
!
process
.
env
.
NEXT_TEST_BROWSER_LOGS
)
{
return
}
return
(
console
[
method
]
as
any
)(
...
args
.
map
((
arg
)
=>
...
args
.
map
((
arg
)
=>
methodsToSkipInspect
.
has
(
method
)
||
methodsToSkipInspect
.
has
(
method
)
||
typeof
arg
!==
'object'
||
typeof
arg
!==
'object'
||
...
@@ -78,7 +84,8 @@ const forwardConsole: typeof console = {
...
@@ -78,7 +84,8 @@ const forwardConsole: typeof console = {
:
// we hardcode depth:Infinity to allow the true depth to be configured by the serialization done in the browser (which is controlled by user)
:
// we hardcode depth:Infinity to allow the true depth to be configured by the serialization done in the browser (which is controlled by user)
util
.
inspect
(
arg
,
{
depth
:
Infinity
,
colors
:
true
})
util
.
inspect
(
arg
,
{
depth
:
Infinity
,
colors
:
true
})
)
)
),
)
},
])
])
),
),
}
}
...
...
test/development/browser-logs/browser-logs.test.ts
View file @
a49c479a
...
@@ -40,6 +40,21 @@ function setupLogCapture() {
...
@@ -40,6 +40,21 @@ function setupLogCapture() {
}
}
describe
(
`Terminal Logging (
${
bundlerName
}
)`
,
()
=>
{
describe
(
`Terminal Logging (
${
bundlerName
}
)`
,
()
=>
{
let
originalBrowserLogsEnv
:
string
|
undefined
beforeAll
(()
=>
{
originalBrowserLogsEnv
=
process
.
env
.
NEXT_TEST_BROWSER_LOGS
process
.
env
.
NEXT_TEST_BROWSER_LOGS
=
'true'
})
afterAll
(()
=>
{
if
(
originalBrowserLogsEnv
===
undefined
)
{
delete
process
.
env
.
NEXT_TEST_BROWSER_LOGS
}
else
{
process
.
env
.
NEXT_TEST_BROWSER_LOGS
=
originalBrowserLogsEnv
}
})
describe
(
'Pages Router'
,
()
=>
{
describe
(
'Pages Router'
,
()
=>
{
let
next
:
NextInstance
let
next
:
NextInstance
let
logs
:
string
[]
=
[]
let
logs
:
string
[]
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment