diff --git a/.gitignore b/.gitignore
index 62f195a..ac276c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -174,4 +174,7 @@ dist
# Finder (MacOS) folder config
.DS_Store
-.vscode
\ No newline at end of file
+.vscode
+# yalc
+.yalc
+yalc.lock
\ No newline at end of file
diff --git a/package.json b/package.json
index a5fb47e..e574cb6 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
"@tscircuit/soup": "^0.0.60",
"@types/bun": "^1.1.8",
"@types/node": "^22.5.2",
- "bun-match-svg": "^0.0.2",
+ "bun-match-svg": "^0.0.3",
"gerber-to-svg": "^4.2.8",
"pcb-stackup": "^4.2.8",
"tsup": "^8.2.4"
diff --git a/tests/__snapshots__/simple1-bottom.snap.svg b/tests/__snapshots__/simple1-bottom.snap.svg
new file mode 100644
index 0000000..940078d
--- /dev/null
+++ b/tests/__snapshots__/simple1-bottom.snap.svg
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/tests/__snapshots__/simple1-top.snap.svg b/tests/__snapshots__/simple1-top.snap.svg
new file mode 100644
index 0000000..32f74d4
--- /dev/null
+++ b/tests/__snapshots__/simple1-top.snap.svg
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/tests/__snapshots__/simple1.snap.svg b/tests/__snapshots__/simple1.snap.svg
deleted file mode 100644
index a79bd2f..0000000
--- a/tests/__snapshots__/simple1.snap.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
\ No newline at end of file
diff --git a/tests/__snapshots__/simple2-bottom.snap.svg b/tests/__snapshots__/simple2-bottom.snap.svg
new file mode 100644
index 0000000..e5c1a22
--- /dev/null
+++ b/tests/__snapshots__/simple2-bottom.snap.svg
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/tests/__snapshots__/simple2-top.snap.svg b/tests/__snapshots__/simple2-top.snap.svg
new file mode 100644
index 0000000..3de5151
--- /dev/null
+++ b/tests/__snapshots__/simple2-top.snap.svg
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/tests/__snapshots__/simple2.snap.svg b/tests/__snapshots__/simple2.snap.svg
deleted file mode 100644
index 62aa963..0000000
--- a/tests/__snapshots__/simple2.snap.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
\ No newline at end of file
diff --git a/tests/fixtures/preload.ts b/tests/fixtures/preload.ts
index d3918dd..5c0d618 100644
--- a/tests/fixtures/preload.ts
+++ b/tests/fixtures/preload.ts
@@ -1,8 +1,7 @@
import "bun-match-svg"
import { expect } from "bun:test"
-import pcbStackup from "pcb-stackup"
+import pcbStackup, { type Stackup } from "pcb-stackup"
import { Readable } from "stream"
-
async function toMatchGerberSnapshot(
this: any,
gerberOutput: Record,
@@ -17,11 +16,20 @@ async function toMatchGerberSnapshot(
try {
const stackup = await pcbStackup(layers)
+ const svgArray: string[] = []
+ const svgNames: string[] = []
- // We'll use the top layer SVG for comparison, but you could choose bottom or both
- const svg = stackup.top.svg
-
- return expect(svg).toMatchSvgSnapshot(testPathOriginal, svgName)
+ for (const item of Object.keys(stackup!) as Array) {
+ const layer = stackup[item] as { svg: string };
+ if (layer.svg) {
+ svgArray.push(layer.svg)
+ svgNames.push(`${svgName}-${item}`)
+ }
+ }
+ return expect(svgArray).toMatchMultipleSvgSnapshots(
+ testPathOriginal,
+ svgNames,
+ )
} catch (error) {
throw new Error(`Failed to generate PCB stackup: ${error}`)
}
diff --git a/tests/generate-board-outline-gerber.test.ts b/tests/generate-board-outline-gerber.test.ts
index 000c760..490ec5b 100644
--- a/tests/generate-board-outline-gerber.test.ts
+++ b/tests/generate-board-outline-gerber.test.ts
@@ -6,7 +6,6 @@ import {
} from "src/stringify-gerber"
import { maybeOutputGerber } from "tests/fixtures/maybe-output-gerber"
import gerberToSvg from "gerber-to-svg"
-
// If you're trying to test this, I would recommend opening up Kicad's Gerber
// Viewer and loading in the files from the generated directory "gerber-output"
// that's produced if OUTPUT_GERBER=1 when you do `npx ava ./tests/gerber/generate-gerber-with-trace.test.ts`
diff --git a/tests/generate-gerber-with-basic-elements.test.ts b/tests/generate-gerber-with-basic-elements.test.ts
index 3739a5f..d1d921d 100644
--- a/tests/generate-gerber-with-basic-elements.test.ts
+++ b/tests/generate-gerber-with-basic-elements.test.ts
@@ -5,7 +5,6 @@ import {
stringifyGerberCommands,
} from "src/stringify-gerber"
import { maybeOutputGerber } from "tests/fixtures/maybe-output-gerber"
-
// If you're trying to test this, I would recommend opening up Kicad's Gerber
// Viewer and loading in the files from the generated directory "gerber-output"
// that's produced if OUTPUT_GERBER=1 when you do `npx ava ./tests/gerber/generate-gerber-with-trace.test.ts`
@@ -70,16 +69,22 @@ test("Generate simple gerber with basic elements", async () => {
outer_diameter: 2,
},
])
- const fu_cp = stringifyGerberCommands(gerber_cmds.F_Cu)
+ const edgecut_gerber = stringifyGerberCommands(gerber_cmds.Edge_Cuts)
// console.log("Gerber")
// console.log("----------------------------------------------")
- // console.log(fu_cp)
- // console.log(stringifyGerberCommands(gerber_cmds.B_Mask))
+ // console.log(edgecut_gerber)
// TODO parse gerber to check for correctness
- const gerbers = stringifyGerberCommandLayers(gerber_cmds)
- await maybeOutputGerber(gerbers)
+ const gerberOutput = stringifyGerberCommandLayers(gerber_cmds)
+
+ await maybeOutputGerber(gerberOutput)
+
+ expect(gerberOutput).toMatchGerberSnapshot(import.meta.path, "simple2")
+
+ // gerberToSvg(gerberOutput.Edge_Cuts, {}, (err, svg) => {
+ // expect(svg).toMatchSvgSnapshot(import.meta.path, "gerber-edge-cuts")
+ // })
- expect(gerbers).toMatchGerberSnapshot(import.meta.path, "simple2")
+ // render(
})