MCPcopy
hub / github.com/processing/p5.js / visualTest

Function visualTest

test/unit/visual/visualTest.js:380–487  ·  view source on GitHub ↗
(
  testName,
  callback,
  { focus = false, skip = false, timeout } = {}
)

Source from the content-addressed store, hash-verified

378 * key `focus` to true to only run this test, or its `skip` key to skip it.
379 */
380export function visualTest(
381 testName,
382 callback,
383 { focus = false, skip = false, timeout } = {}
384) {
385 let suiteFn = describe;
386 if (focus) {
387 suiteFn = suiteFn.only;
388 }
389 if (skip) {
390 suiteFn = suiteFn.skip;
391 }
392
393 suiteFn(testName, function() {
394 let name;
395 let myp5;
396 let lastDeviceRatio = window.devicePixelRatio;
397
398 beforeAll(function() {
399 name = namePrefix + escapeName(testName);
400 // Force everything to be 1x
401 window.devicePixelRatio = 1;
402 return new Promise(res => {
403 myp5 = new p5(function(p) {
404 p.setup = function() {
405 res();
406 };
407 });
408 });
409 });
410
411 afterAll(function() {
412 window.devicePixelRatio = lastDeviceRatio;
413 myp5.remove();
414 });
415
416 test('matches expected screenshots', async function() {
417 let expectedScreenshots;
418 try {
419 const metadata = JSON.parse(await readFile(
420 `./test/unit/visual/screenshots/${name}/metadata.json`
421 ));
422 expectedScreenshots = metadata.numScreenshots;
423 } catch (e) {
424 console.log(e);
425 expectedScreenshots = 0;
426 }
427
428 const actual = [];
429
430 // Generate screenshots
431 await callback(myp5, async () => {
432 const img = await myp5.get();
433 img.pixelDensity(1);
434 actual.push(img);
435 });
436
437

Callers 6

typography.jsFile · 0.90
shape_modes.jsFile · 0.90
webgpu.jsFile · 0.90
shapes.jsFile · 0.90
webgl.jsFile · 0.90
noise.jsFile · 0.90

Calls 10

escapeNameFunction · 0.85
checkMatchFunction · 0.85
writeImageFileFunction · 0.85
toBase64Function · 0.85
sliceMethod · 0.80
removeMethod · 0.45
getMethod · 0.45
pixelDensityMethod · 0.45
pushMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected