Skip to content

Commit

Permalink
updated jest setup file and updated snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalkSimplify committed Oct 3, 2023
1 parent b3e59b5 commit 472606e
Show file tree
Hide file tree
Showing 2 changed files with 347 additions and 317 deletions.
34 changes: 32 additions & 2 deletions jest-setup.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
// Jest setup provided by Grafana scaffolding
import './.config/jest-setup';
// jest.setup.js

// Polyfill TextEncoder for jsdom environment
if (typeof TextEncoder === 'undefined') {
const { TextEncoder } = require('util');
global.TextEncoder = TextEncoder;
}

// Mock matchMedia for window.matchMedia used by some components
Object.defineProperty(global, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(),
removeListener: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});

// Mock HTMLCanvasElement.prototype.getContext used by some components
HTMLCanvasElement.prototype.getContext = () => {};

// Import jest-dom to extend Jest's expect with matchers for DOM elements
import '@testing-library/jest-dom';

// Import Grafana's Jest setup
import './.config/jest-setup';

Loading

0 comments on commit 472606e

Please sign in to comment.