Skip to content

[Test] Fix: Add global canvas mock to improve test stability.Β #5972

@Rudra2637

Description

@Rudra2637

What needs testing

While running the test suite (npm test), I observed repeated warnings in the console: Not implemented: HTMLCanvasElement.prototype.getContext
The tests pass successfully, but this warning appears multiple times during execution.

This seems to occur because jsdom does not implement canvas rendering APIs by default, and HTMLCanvasElement.getContext is not globally mocked in the Jest environment.

Current coverage

All existing test suites pass (120/120), and coverage is being collected correctly.

However, the test environment logs repeated jsdom warnings related to canvas rendering, which results in noisy output and may affect CI clarity.

Proposed approach

Add a global Jest setup file to mock:

HTMLCanvasElement.prototype.getContext

I am willing to contribute to this approach if it gets approved.

Checklist

  • I have read and followed the project's code of conduct.
  • I have checked that no existing tests cover this area.
  • I have checked that there is no open PR for the tests I am submitting.
  • I have reviewed docs/TESTING.md for testing patterns.

πŸ“š See Testing Guide for how to write block tests.

πŸ™‹πŸΎπŸ™‹πŸΌ Questions: Community Matrix Server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions