Skip to content

Commit

Permalink
3d snapshotting via playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed Jan 8, 2025
1 parent 9427ebe commit 038bb9c
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ tmp*
*.diff.png
.env
.DS_Store
search-result.json
search-result.json
playwright-report
test-results
Binary file modified bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@playwright/test": "^1.49.1",
"@tscircuit/log-soup": "1.0.2",
"@tscircuit/props": "^0.0.128",
"@tscircuit/runframe": "^0.0.72",
Expand All @@ -38,6 +39,7 @@
"circuit-json": "^0.0.129",
"circuit-to-svg": "^0.0.99",
"class-variance-authority": "^0.7.1",
"playwright": "^1.49.1",
"react": "18",
"react-dom": "18",
"tsup": "^8.1.0",
Expand Down
10 changes: 10 additions & 0 deletions playwright-tests/c14877.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { test, expect } from "@playwright/test"

test("c14877", async ({ page }) => {
await page.goto("http://localhost:5181?jlcpcb_part_number=C14877")

await page.waitForSelector("#code-content", { state: "visible" })
await page.waitForLoadState("networkidle")

await expect(page).toHaveScreenshot()
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { defineConfig, devices } from "@playwright/test"
import { defineConfig as defineViteConfig } from "vite"
import { createServer } from "vite"

export default defineConfig({
testDir: "./playwright-tests",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: "html",
use: {
baseURL: "http://localhost:5181",
trace: "on-first-retry",
},
webServer: {
command: "npm run start -- --port 5181",
url: "http://localhost:5181",
reuseExistingServer: !process.env.CI,
stdout: "pipe",
stderr: "pipe",
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
})
6 changes: 5 additions & 1 deletion site/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default () => {
return (
<div>
<RunFrame
defaultActiveTab="cad"
entrypoint="entrypoint.tsx"
fsMap={{
"entrypoint.tsx": `
Expand All @@ -60,7 +61,10 @@ circuit.add(<board width="10mm" height="10mm"><Component name="U1" /></board>)
"snippet.tsx": tscircuitCode,
}}
/>
<pre className="bg-gray-100 p-4 rounded-lg overflow-x-auto">
<pre
id="code-content"
className="bg-gray-100 p-4 rounded-lg overflow-x-auto"
>
<code className="text-sm font-mono">{tscircuitCode}</code>
</pre>
</div>
Expand Down

0 comments on commit 038bb9c

Please sign in to comment.