Skip to content

Commit e670cdd

Browse files
committed
Render external symbols in snapshots
Amp-Thread-ID: https://ampcode.com/threads/T-01a029e2-5095-710a-9cce-0c6d8645c173
1 parent 3242e33 commit e670cdd

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

snapshots/input/react/src/LoaderInput.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// format-options: showExternalSymbols
2+
13
import React from 'react'
24

35
/** Takes loading prop, input component as child */

snapshots/output/react/src/LoaderInput.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
// language TypeScriptReact
22
// < definition react-example 1.0.0 src/`LoaderInput.tsx`/
33

4+
// format-options: showExternalSymbols
5+
46
import React from 'react'
57
// ^^^^^ reference @types/react 19.2.18 `index.d.ts`/React/
8+
// external SymbolInformation @types/react 19.2.18 `index.d.ts`/React/
69
// ^^^^^^^ reference @types/react 19.2.18 `index.d.ts`/
10+
// external SymbolInformation @types/react 19.2.18 `index.d.ts`/
711

812
/** Takes loading prop, input component as child */
913
interface Props {
@@ -14,12 +18,14 @@ interface Props {
1418
//^^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/Props#children.
1519
// ^^^^^ reference @types/react 19.2.18 `index.d.ts`/React/
1620
// ^^^^^^^^^ reference @types/react 19.2.18 `index.d.ts`/React/ReactNode#
21+
// external SymbolInformation @types/react 19.2.18 `index.d.ts`/React/ReactNode#
1722
}
1823

1924
export const LoaderInput: React.FunctionComponent<Props> = ({
2025
// ^^^^^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/LoaderInput.
2126
// ^^^^^ reference @types/react 19.2.18 `index.d.ts`/React/
2227
// ^^^^^^^^^^^^^^^^^ reference @types/react 19.2.18 `index.d.ts`/React/FunctionComponent#
28+
// external SymbolInformation @types/react 19.2.18 `index.d.ts`/React/FunctionComponent#
2329
// ^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#
2430
loading,
2531
//^^^^^^^ definition local 3
@@ -30,12 +36,15 @@ export const LoaderInput: React.FunctionComponent<Props> = ({
3036
}) => (
3137
<div className="hello">
3238
// ^^^ reference @types/react 19.2.18 `index.d.ts`/React/JSX/IntrinsicElements#div.
39+
// external SymbolInformation @types/react 19.2.18 `index.d.ts`/React/JSX/IntrinsicElements#div.
3340
// ^^^^^^^^^ reference @types/react 19.2.18 `index.d.ts`/React/HTMLAttributes#className.
41+
// external SymbolInformation @types/react 19.2.18 `index.d.ts`/React/HTMLAttributes#className.
3442
{children}
3543
// ^^^^^^^^ reference local 4
3644
{loading && <p>spinner</p>}
3745
// ^^^^^^^ reference local 3
3846
// ^ reference @types/react 19.2.18 `index.d.ts`/React/JSX/IntrinsicElements#p.
47+
// external SymbolInformation @types/react 19.2.18 `index.d.ts`/React/JSX/IntrinsicElements#p.
3948
// ^ reference @types/react 19.2.18 `index.d.ts`/React/JSX/IntrinsicElements#p.
4049
</div>
4150
// ^^^ reference @types/react 19.2.18 `index.d.ts`/React/JSX/IntrinsicElements#div.
@@ -51,6 +60,7 @@ export const LoaderInput2: React.FunctionComponent<Props> = props => {
5160
// ^^^^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/LoaderInput.
5261
// ^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#loading.
5362
// ^^^ reference @types/react 19.2.18 `index.d.ts`/React/Attributes#key.
63+
// external SymbolInformation @types/react 19.2.18 `index.d.ts`/React/Attributes#key.
5464
// ^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#children.
5565
// ^^^^^ reference local 6
5666
// ^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#children.

src/SnapshotTesting.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ function getSymbolTable(
1818

1919
function parseOptions(lines: string[]): {
2020
showDocs: boolean
21+
showExternalSymbols: boolean
2122
showKinds: boolean
2223
showRanges: boolean
2324
} {
2425
const formatOptions = {
2526
showDocs: false,
27+
showExternalSymbols: false,
2628
showKinds: false,
2729
showRanges: false,
2830
}
@@ -184,6 +186,10 @@ export function formatSnapshot(
184186

185187
const externalSymbol = externalSymbolTable.get(symbol)
186188
if (externalSymbol) {
189+
if (formatOptions.showExternalSymbols) {
190+
out.push(prefix)
191+
out.push(`external SymbolInformation ${symbolNameForSnapshot(symbol)}`)
192+
}
187193
pushKind(externalSymbol.kind)
188194
pushOneDoc(externalSymbol.documentation, true)
189195
pushOneRelationship(externalSymbol.relationships)

0 commit comments

Comments
 (0)