-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checkpoint gerber rendering with snapshots
- Loading branch information
Showing
6 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[test] | ||
preload = ["./tests/fixtures/preload.ts"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import "bun-match-svg" | ||
import { expect } from "bun:test" | ||
import gerberToSvg from "gerber-to-svg" | ||
|
||
async function toMatchGerberSnapshot( | ||
this: any, | ||
gerberOutput: Record<string, string>, | ||
testPathOriginal: string, | ||
svgName?: string, | ||
) { | ||
const svg = await new Promise((resolve, reject) => { | ||
gerberToSvg(gerberOutput.Edge_Cuts, {}, (err, svg) => { | ||
if (err) return reject(err) | ||
resolve(svg) | ||
}) | ||
}) | ||
|
||
return expect(svg).toMatchSvgSnapshot(import.meta.path, svgName) | ||
} | ||
|
||
expect.extend({ | ||
// biome-ignore lint/suspicious/noExplicitAny: | ||
toMatchGerberSnapshot: toMatchGerberSnapshot as any, | ||
}) | ||
|
||
declare module "bun:test" { | ||
interface Matchers<T = unknown> { | ||
toMatchGerberSnapshot( | ||
testPath: string, | ||
svgName?: string, | ||
): Promise<MatcherResult> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters