Naite Viewer is a feature included in the Sonamu VSCode Extension that visualizes Naite logs recorded during test execution in real-time.Naite transmits all data recorded with Naite.t() during test execution to the VSCode Extension, allowing developers to visually track test flows. This is especially useful for complex business logic or situations involving multiple intertwined function calls.
Immediately displays all logs recorded with Naite.t() during test execution in the VSCode panel. View structured logs without searching through the console.
2
Grouping by Test
Automatically groups logs by test case. Also categorized by Suite, so you can quickly find desired logs even in large-scale tests.
3
Callstack Tracking
Displays the call location and full callstack information for each log. Click on a log to navigate directly to that code location.
4
Filtering and Search
Filter logs from specific modules using wildcard patterns (user:*), or search log contents by keyword.
Naite Viewer communicates with the test process through Unix Socket. This method allows direct inter-process communication without using the file system, making it fast and secure.Benefits of socket communication:
Fast transmission: Much faster IPC (Inter-Process Communication) than HTTP or files
Real-time: Logs are delivered to Extension immediately as tests run
Isolation: Independent sockets per project prevent conflicts
Socket path rules:
macOS / Linux
Windows
Copy
~/.sonamu/naite-{hash}.sock
{hash} is the first 8 characters of the MD5 hash of the sonamu.config.ts path.
Copy
\\.\pipe\naite-{hash}
Uses Windows Named Pipe.
See Hash Generation Method in Detail
Each project generates a unique hash based on the absolute path of the sonamu.config.ts file:
Let’s look at the order in which messages are sent throughout the test execution process.
Transmission Flow in Code
Copy
// 1. Test start - Socket connection and run/start sendbeforeAll(async () => { await NaiteReporter.startTestRun(); // → send({ type: "run/start" })});// 2. Test execution - Naite log collectiontest("create user", async () => { Naite.t("user:create:input", { username: "john" }); const { user } = await userModel.create({ username: "john" }); Naite.t("user:create:output", { userId: user.id }); // afterEach runs after test ends});// 3. Test end - traces collection and sendafterEach(async ({ task }) => { // Collect all Naite logs with getAllTraces() task.meta.traces = Naite.getAllTraces(); // Send to Extension await NaiteReporter.reportTestResult({ testName: task.name, status: task.result?.state, traces: task.meta.traces, // ... }); // → send({ type: "test/result", traces: [...] })});// 4. Full run end - run/end send and socket closeafterAll(() => { await NaiteReporter.endTestRun(); // → send({ type: "run/end" }) // → socket.end()});
Buffering Mechanism: If the Extension hasn’t started yet or socket connection is delayed, NaiteReporter stores messages in a buffer and sends them all at once when connection succeeds. This allows you to see previous test logs even if you start the Extension late.
The Extension automatically starts the socket server when it runs:
1
Project Detection
Finds the sonamu.config.ts file in the current workspace.
2
Hash Calculation
Generates an MD5 hash (first 8 characters) from the absolute path of sonamu.config.ts.
3
Socket Server Start
Starts a Unix Socket server at ~/.sonamu/naite-{hash}.sock.
4
Wait for Test Process
NaiteReporter connects to this socket when tests run.
The Extension creates sockets based on project path, so you must open the project folder directly for it to work properly. Opening a parent folder may result in different socket paths that don’t connect.
Click each callstack frame to navigate to code location
Test logs displayed in actual Naite Viewer (Suite > Test > Trace hierarchy)
Real-time Updates: In watch mode, when you modify a file, tests auto-rerun and the Viewer updates immediately. This lets you see the impact of code changes right away.
Click on a log to see detailed information about that Naite.t() call.
Callstack Information Example
Copy
user:create:input{ username: "john", email: "john@example.com" }📍 Direct call location: /Users/.../user.model.test.ts:20📚 Full callstack: 1. test (user.model.test.ts:20) ↑ Click to navigate to this location 2. createUser (user.model.ts:45) 3. runWithMockContext (bootstrap.ts:58)
Callstack meaning:
test (line 20): Location where Naite.t() was called in test code
createUser (line 45): Actual business logic called by test
runWithMockContext: Sonamu’s Context wrapper (displayed up to here)
Callstack information and code navigation feature when clicking on a log
Clicking each item in the callstack navigates directly to the exact line in that file. This is especially useful for debugging complex call chains.
request/response Pattern: Logging :request and :response before and after API calls allows clear tracking of each API’s inputs and outputs. This is especially useful in integration tests.
Importance of Callstack for Errors: The Viewer’s callstack info shows the exact code line where the error occurred. This is especially useful for complex call chains that are hard to figure out with console.log.
# Project A/Users/noa/project-a/api/src/sonamu.config.ts→ ~/.sonamu/naite-a1b2c3d4.sock# Project B/Users/noa/project-b/api/src/sonamu.config.ts→ ~/.sonamu/naite-e5f6g7h8.sock# Each uses independent socket# Extension connects to different socket per project
Benefits:
Complete isolation of logs between projects
Simultaneous execution support (test A while testing B)
When modifying files multiple times in watch mode, previous test logs may remain.
Auto Clear: When run/start message is sent, Extension automatically clears previous logs. However, manual clearing may be needed when working on multiple projects simultaneously.
Manual clear methods:
Click “Clear All” button at top of Naite Viewer panel
Extension required: VSCode Extension must be running. Running only tests without Extension causes logs to accumulate in buffer and disappear.
Local only: Socket communication may be restricted on remote servers (SSH, Codespaces, etc.). Use in local development environment.
Auto disable in CI: Socket communication is automatically disabled in CI environments (process.env.CI). No errors occur.
Per-project independence: Each project uses an independent socket. When working on multiple projects simultaneously, verify you’re looking at the correct Viewer window.
Serialization required: Values sent to Extension are serialized to JSON. Passing functions or circular reference objects to Naite.t() will show a warning.
Avoid excessive logging: Calling Naite.t() inside loops can create thousands of logs, degrading performance.