Files
tcb_devportal/jest.setup.js
duynguyen c90a36a54f
Some checks failed
homelab-k8s-services/tcb_devportal/pipeline/head There was a failure building this commit
feat: initial commit — tcb_devportal Next.js app
Includes Helm chart (tcb-devportal), Jenkinsfile with homelab CI pipeline,
and Next.js app source.
2026-05-10 14:49:10 +07:00

53 lines
1.5 KiB
JavaScript

/* eslint-disable @typescript-eslint/no-require-imports -- Jest setup runs in Node with CommonJS */
require('@testing-library/jest-dom')
process.env.NEXT_PUBLIC_BACK_END_DOMAIN =
process.env.NEXT_PUBLIC_BACK_END_DOMAIN || 'http://localhost/api/v1'
process.env.NEXT_PUBLIC_TIME_OUT_API =
process.env.NEXT_PUBLIC_TIME_OUT_API || '60000'
if (
(typeof globalThis.crypto === 'undefined' ||
typeof globalThis.crypto.randomUUID !== 'function') &&
typeof require('crypto').randomUUID === 'function'
) {
const nodeCrypto = require('crypto')
globalThis.crypto = globalThis.crypto || {}
globalThis.crypto.randomUUID = nodeCrypto.randomUUID.bind(nodeCrypto)
}
const mockLocalStorage = {
getItem: jest.fn(),
setItem: jest.fn(),
removeItem: jest.fn(),
clear: jest.fn(),
}
global.localStorage = mockLocalStorage
if (typeof window !== 'undefined') {
window.localStorage = mockLocalStorage
}
class MockResizeObserver {
observe = jest.fn()
unobserve = jest.fn()
disconnect = jest.fn()
}
class MockBroadcastChannel {
postMessage = jest.fn()
close = jest.fn()
onmessage = null
}
global.ResizeObserver = global.ResizeObserver || MockResizeObserver
global.BroadcastChannel = global.BroadcastChannel || MockBroadcastChannel
if (typeof window !== 'undefined') {
window.ResizeObserver = window.ResizeObserver || MockResizeObserver
window.BroadcastChannel = window.BroadcastChannel || MockBroadcastChannel
}
if (!Element.prototype.scrollIntoView) {
Element.prototype.scrollIntoView = jest.fn()
}