diff --git a/.pnp.cjs b/.pnp.cjs index 3a96d880..35c12ee5 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -4693,6 +4693,7 @@ const RAW_RUNTIME_STATE = ["@testing-library/react", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:16.3.0"],\ ["@types/react", "npm:19.1.0"],\ ["@types/react-dom", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:19.1.2"],\ + ["@vitest/coverage-v8", "virtual:b8ca648f23ac8db9e48f501f3417b5d22664f520096d4c3f324c7f27acb059637b178631fb2aa9474c5307a2c176eb80c2a4069538d26cb000262efba27773fe#npm:2.1.9"],\ ["eslint", "virtual:b8ca648f23ac8db9e48f501f3417b5d22664f520096d4c3f324c7f27acb059637b178631fb2aa9474c5307a2c176eb80c2a4069538d26cb000262efba27773fe#npm:9.24.0"],\ ["react", "npm:19.1.0"],\ ["react-dom", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:19.1.0"],\ @@ -4715,6 +4716,7 @@ const RAW_RUNTIME_STATE = ["@testing-library/react", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:16.3.0"],\ ["@types/react", "npm:19.1.0"],\ ["@types/react-dom", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:19.1.2"],\ + ["@vitest/coverage-v8", "virtual:b8ca648f23ac8db9e48f501f3417b5d22664f520096d4c3f324c7f27acb059637b178631fb2aa9474c5307a2c176eb80c2a4069538d26cb000262efba27773fe#npm:2.1.9"],\ ["eslint", "virtual:b8ca648f23ac8db9e48f501f3417b5d22664f520096d4c3f324c7f27acb059637b178631fb2aa9474c5307a2c176eb80c2a4069538d26cb000262efba27773fe#npm:9.24.0"],\ ["react", "npm:19.1.0"],\ ["react-dom", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:19.1.0"],\ @@ -5995,6 +5997,35 @@ const RAW_RUNTIME_STATE = "vitest"\ ],\ "linkType": "HARD"\ + }],\ + ["virtual:b8ca648f23ac8db9e48f501f3417b5d22664f520096d4c3f324c7f27acb059637b178631fb2aa9474c5307a2c176eb80c2a4069538d26cb000262efba27773fe#npm:2.1.9", {\ + "packageLocation": "./.yarn/__virtual__/@vitest-coverage-v8-virtual-5fcb5057e8/0/cache/@vitest-coverage-v8-npm-2.1.9-95e7812374-ccf5871954.zip/node_modules/@vitest/coverage-v8/",\ + "packageDependencies": [\ + ["@ampproject/remapping", "npm:2.3.0"],\ + ["@bcoe/v8-coverage", "npm:0.2.3"],\ + ["@types/vitest", null],\ + ["@types/vitest__browser", null],\ + ["@vitest/browser", null],\ + ["@vitest/coverage-v8", "virtual:b8ca648f23ac8db9e48f501f3417b5d22664f520096d4c3f324c7f27acb059637b178631fb2aa9474c5307a2c176eb80c2a4069538d26cb000262efba27773fe#npm:2.1.9"],\ + ["debug", "virtual:643ed7cc338bcf145a82d8b05b3bef6bcf150ca545df386225596f10ce53cc90b88b3ca83e348ade1ccea5f3f8e76c92d2f0e2ba544da60d40aff9921c56872d#npm:4.4.0"],\ + ["istanbul-lib-coverage", "npm:3.2.2"],\ + ["istanbul-lib-report", "npm:3.0.1"],\ + ["istanbul-lib-source-maps", "npm:5.0.6"],\ + ["istanbul-reports", "npm:3.1.7"],\ + ["magic-string", "npm:0.30.17"],\ + ["magicast", "npm:0.3.5"],\ + ["std-env", "npm:3.9.0"],\ + ["test-exclude", "npm:7.0.1"],\ + ["tinyrainbow", "npm:1.2.0"],\ + ["vitest", "virtual:b8ca648f23ac8db9e48f501f3417b5d22664f520096d4c3f324c7f27acb059637b178631fb2aa9474c5307a2c176eb80c2a4069538d26cb000262efba27773fe#npm:2.1.9"]\ + ],\ + "packagePeers": [\ + "@types/vitest",\ + "@types/vitest__browser",\ + "@vitest/browser",\ + "vitest"\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@vitest/expect", [\ diff --git a/packages/mobile/package.json b/packages/mobile/package.json index de61c004..e147bfe8 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -61,6 +61,7 @@ "@testing-library/react": "^16.1.0", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", + "@vitest/coverage-v8": "^2.1.8", "eslint": "^9.16.0", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/packages/mobile/src/hooks/keyboardHeight/useKeyboardHeight.ssr.test.ts b/packages/mobile/src/hooks/keyboardHeight/useKeyboardHeight.ssr.test.ts new file mode 100644 index 00000000..771b389f --- /dev/null +++ b/packages/mobile/src/hooks/keyboardHeight/useKeyboardHeight.ssr.test.ts @@ -0,0 +1,25 @@ +/** + * @vitest-environment node + * + * SSR environment tests - runs in Node.js where window is truly undefined + */ +import { describe, expect, it } from 'vitest'; + +import { useKeyboardHeight } from './useKeyboardHeight.ts'; + +describe('useKeyboardHeight SSR environment', () => { + it('should be safe on server side rendering', () => { + expect(typeof window).toBe('undefined'); + + // Should not throw during module evaluation + expect(() => useKeyboardHeight).not.toThrow(); + }); + + it('should not throw when imported in SSR', () => { + // In Node environment, window is undefined + expect(typeof window).toBe('undefined'); + + // Just verify the hook can be called (doesn't actually run without React context) + expect(typeof useKeyboardHeight).toBe('function'); + }); +}); diff --git a/packages/mobile/src/hooks/useAvoidKeyboard/useAvoidKeyboard.ssr.test.ts b/packages/mobile/src/hooks/useAvoidKeyboard/useAvoidKeyboard.ssr.test.ts new file mode 100644 index 00000000..aa8e3735 --- /dev/null +++ b/packages/mobile/src/hooks/useAvoidKeyboard/useAvoidKeyboard.ssr.test.ts @@ -0,0 +1,25 @@ +/** + * @vitest-environment node + * + * SSR environment tests - runs in Node.js where window is truly undefined + */ +import { describe, expect, it } from 'vitest'; + +import { useAvoidKeyboard } from './useAvoidKeyboard.ts'; + +describe('useAvoidKeyboard SSR environment', () => { + it('should be safe on server side rendering', () => { + expect(typeof window).toBe('undefined'); + + // Should not throw during module evaluation + expect(() => useAvoidKeyboard).not.toThrow(); + }); + + it('should not throw when imported in SSR', () => { + // In Node environment, window is undefined + expect(typeof window).toBe('undefined'); + + // Just verify the hook can be called (doesn't actually run without React context) + expect(typeof useAvoidKeyboard).toBe('function'); + }); +}); diff --git a/packages/mobile/src/hooks/useNetworkStatus/useNetworkStatus.ssr.test.ts b/packages/mobile/src/hooks/useNetworkStatus/useNetworkStatus.ssr.test.ts new file mode 100644 index 00000000..e019e809 --- /dev/null +++ b/packages/mobile/src/hooks/useNetworkStatus/useNetworkStatus.ssr.test.ts @@ -0,0 +1,25 @@ +/** + * @vitest-environment node + * + * SSR environment tests - runs in Node.js where window is truly undefined + */ +import { describe, expect, it } from 'vitest'; + +import { useNetworkStatus } from './useNetworkStatus.ts'; + +describe('useNetworkStatus SSR environment', () => { + it('should be safe on server side rendering', () => { + expect(typeof window).toBe('undefined'); + + // Should not throw during module evaluation + expect(() => useNetworkStatus).not.toThrow(); + }); + + it('should not throw when imported in SSR', () => { + // In Node environment, window is undefined + expect(typeof window).toBe('undefined'); + + // Just verify the hook can be called (doesn't actually run without React context) + expect(typeof useNetworkStatus).toBe('function'); + }); +}); diff --git a/packages/mobile/src/hooks/usePageVisibility/usePageVisibility.ssr.test.ts b/packages/mobile/src/hooks/usePageVisibility/usePageVisibility.ssr.test.ts new file mode 100644 index 00000000..71a7b132 --- /dev/null +++ b/packages/mobile/src/hooks/usePageVisibility/usePageVisibility.ssr.test.ts @@ -0,0 +1,25 @@ +/** + * @vitest-environment node + * + * SSR environment tests - runs in Node.js where window is truly undefined + */ +import { describe, expect, it } from 'vitest'; + +import { usePageVisibility } from './usePageVisibility.ts'; + +describe('usePageVisibility SSR environment', () => { + it('should be safe on server side rendering', () => { + expect(typeof window).toBe('undefined'); + + // Should not throw during module evaluation + expect(() => usePageVisibility).not.toThrow(); + }); + + it('should not throw when imported in SSR', () => { + // In Node environment, window is undefined + expect(typeof window).toBe('undefined'); + + // Just verify the hook can be called (doesn't actually run without React context) + expect(typeof usePageVisibility).toBe('function'); + }); +}); diff --git a/yarn.lock b/yarn.lock index c8a364aa..d446ae95 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3685,6 +3685,7 @@ __metadata: "@testing-library/react": "npm:^16.1.0" "@types/react": "npm:^19.0.0" "@types/react-dom": "npm:^19.0.0" + "@vitest/coverage-v8": "npm:^2.1.8" eslint: "npm:^9.16.0" react: "npm:^19.0.0" react-dom: "npm:^19.0.0"