Skip to content

[p5.js 2.0+ Bug Report]: A saveCanvas test is flaky #9030

Description

@davepagurek

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • WebGPU
  • p5.strands
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

main branch

Web browser and version

N/A

Operating system

N/A

Steps to reproduce this

Sometimes on PRs, tests will fail with this error:

 FAIL   unit-tests (chrome)  test/unit/webgl/p5.Framebuffer.js > p5.Framebuffer > saveCanvas > should download a png file
AssertionError: expected "createElement" to be called with arguments: [ 'a' ]

Received: 

  1st createElement call:

  [
-   "a",
+   "canvas",
  ]

  2nd createElement call:

  [
-   "a",
+   "canvas",
  ]


Number of calls: 2

 ❯ test/unit/webgl/p5.Framebuffer.js:681:38
    679|       await new Promise(res => setTimeout(res, 500));
    680| 
    681|       expect(document.createElement).toHaveBeenCalledWith('a');
       |                                      ^

    682|       expect(mockAnchorElement.click).toHaveBeenCalledTimes(1);
    683|       assert.equal(mockAnchorElement.download, 'untitled.png');

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

 Test Files  1 failed | 67 passed | 4 skipped (72)
      Tests  1 failed | 2032 passed | 12 skipped | 213 todo (2258)
   Start at  17:15:00
   Duration  128.19s (transform 0ms, setup 0ms, import 30.75s, tests 70.80s, environment 0ms)


Error: AssertionError: expected "createElement" to be called with arguments: [ 'a' ]

Received: 

  1st createElement call:

  [
-   "a",
+   "canvas",
  ]

  2nd createElement call:

  [
-   "a",
+   "canvas",
  ]


Number of calls: 2

 ❯ test/unit/webgl/p5.Framebuffer.js:681:38

This isn't a real failure, it's a flaky test. Anyone have ideas on ways we can rewrite it to not be flaky?

Metadata

Metadata

Type

No type

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions