-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
21 additions
and
153 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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import * as _2d from '../demos/2d'; | ||
import * as d3 from '../demos/d3'; | ||
import { generateCanvasTestCase } from './canvas'; | ||
import { generateCanvasTestCase } from './utils/generator'; | ||
|
||
describe('Canvas Snapshot', () => { | ||
generateCanvasTestCase('2d', _2d); | ||
// generateCanvasTestCase('d3', d3); | ||
generateCanvasTestCase('canvas', '2d', _2d); | ||
generateCanvasTestCase('canvas', 'd3', d3); | ||
}); |
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 |
---|---|---|
@@ -1,41 +1,8 @@ | ||
import { chromium, devices } from 'playwright'; | ||
import * as basic2d from '../demos/2d'; | ||
import './utils/useSnapshotMatchers'; | ||
import { sleep } from './utils/sleep'; | ||
import * as _2d from '../demos/2d'; | ||
import * as d3 from '../demos/d3'; | ||
import { generateCanvasTestCase } from './utils/generator'; | ||
|
||
const namespace = '2d'; | ||
describe('SVG Snapshot', () => { | ||
Object.keys(basic2d).forEach((key) => { | ||
it(key, async () => { | ||
// Setup | ||
const browser = await chromium.launch({ | ||
args: ['--headless', '--no-sandbox'], | ||
}); | ||
const context = await browser.newContext(devices['Desktop Chrome']); | ||
const page = await context.newPage(); | ||
|
||
await page.addInitScript(() => { | ||
window['USE_PLAYWRIGHT'] = 1; | ||
window['DEFAULT_RENDERER'] = 'svg'; | ||
}); | ||
|
||
// Go to test page served by vite devServer. | ||
const url = `http://localhost:${globalThis.PORT}/?name=${namespace}-${key}`; | ||
await page.goto(url); | ||
|
||
await sleep(300); | ||
|
||
// Chart already rendered, capture into buffer. | ||
const buffer = await page.locator('svg').screenshot(); | ||
|
||
const dir = `${__dirname}/snapshots/${namespace}/svg`; | ||
try { | ||
const maxError = 0; | ||
expect(buffer).toMatchCanvasSnapshot(dir, key, { maxError }); | ||
} finally { | ||
await context.close(); | ||
await browser.close(); | ||
} | ||
}); | ||
}); | ||
generateCanvasTestCase('svg', '2d', _2d); | ||
generateCanvasTestCase('svg', 'd3', d3); | ||
}); |
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,41 +1,8 @@ | ||
import { chromium, devices } from 'playwright'; | ||
import * as basic2d from '../demos/2d'; | ||
import './utils/useSnapshotMatchers'; | ||
import { sleep } from './utils/sleep'; | ||
import * as _2d from '../demos/2d'; | ||
import * as d3 from '../demos/d3'; | ||
import { generateCanvasTestCase } from './utils/generator'; | ||
|
||
const namespace = '2d'; | ||
describe('WebGL Snapshot', () => { | ||
Object.keys(basic2d).forEach((key) => { | ||
it(key, async () => { | ||
// Setup | ||
const browser = await chromium.launch({ | ||
args: ['--headless', '--no-sandbox'], | ||
}); | ||
const context = await browser.newContext(devices['Desktop Chrome']); | ||
const page = await context.newPage(); | ||
|
||
await page.addInitScript(() => { | ||
window['USE_PLAYWRIGHT'] = 1; | ||
window['DEFAULT_RENDERER'] = 'webgl'; | ||
}); | ||
|
||
// Go to test page served by vite devServer. | ||
const url = `http://localhost:${globalThis.PORT}/?name=${namespace}-${key}`; | ||
await page.goto(url); | ||
|
||
await sleep(300); | ||
|
||
// Chart already rendered, capture into buffer. | ||
const buffer = await page.locator('canvas').screenshot(); | ||
|
||
const dir = `${__dirname}/snapshots/${namespace}/webgl`; | ||
try { | ||
const maxError = 0; | ||
expect(buffer).toMatchCanvasSnapshot(dir, key, { maxError }); | ||
} finally { | ||
await context.close(); | ||
await browser.close(); | ||
} | ||
}); | ||
}); | ||
generateCanvasTestCase('webgl', '2d', _2d); | ||
generateCanvasTestCase('webgl', 'd3', d3); | ||
}); |