node-version-check.test.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * Pin the Node-25 block banner content. The banner replaced a soft
  3. * `console.warn` because the warning was scrolling off-screen before
  4. * the OOM crash 30 seconds later, generating duplicate bug reports
  5. * (#54, #81, #140). The recipe and override env var below are
  6. * load-bearing — if any of them get edited away, this test catches it.
  7. */
  8. import { describe, it, expect } from 'vitest';
  9. import { buildNode25BlockBanner, buildNodeTooOldBanner, MIN_NODE_MAJOR } from '../src/bin/node-version-check';
  10. describe('buildNode25BlockBanner', () => {
  11. it('embeds the reported Node version in the header', () => {
  12. expect(buildNode25BlockBanner('25.9.0')).toContain(
  13. 'Unsupported Node.js version: 25.9.0'
  14. );
  15. });
  16. it('names the V8 turboshaft WASM root cause and the OOM symptom', () => {
  17. const banner = buildNode25BlockBanner('25.7.0');
  18. expect(banner).toContain('V8 WASM JIT');
  19. expect(banner).toContain('turboshaft');
  20. expect(banner).toContain('Fatal process out of memory: Zone');
  21. });
  22. it('points users to Node 22 LTS via nvm and Homebrew', () => {
  23. const banner = buildNode25BlockBanner('25.7.0');
  24. expect(banner).toContain('Node.js 22 LTS');
  25. expect(banner).toContain('nvm install 22');
  26. expect(banner).toContain('brew install node@22');
  27. });
  28. it('documents the CODEGRAPH_ALLOW_UNSAFE_NODE override', () => {
  29. const banner = buildNode25BlockBanner('25.7.0');
  30. expect(banner).toContain('CODEGRAPH_ALLOW_UNSAFE_NODE=1');
  31. });
  32. it('links to issue #81 for the root-cause writeup', () => {
  33. expect(buildNode25BlockBanner('25.7.0')).toContain(
  34. 'github.com/colbymchenry/codegraph/issues/81'
  35. );
  36. });
  37. });
  38. describe('buildNodeTooOldBanner', () => {
  39. it('embeds the reported Node version in the header', () => {
  40. expect(buildNodeTooOldBanner('18.20.0')).toContain(
  41. 'Unsupported Node.js version: 18.20.0'
  42. );
  43. });
  44. it('states the supported floor matching MIN_NODE_MAJOR', () => {
  45. expect(MIN_NODE_MAJOR).toBe(20);
  46. expect(buildNodeTooOldBanner('18.0.0')).toContain(
  47. `requires Node.js ${MIN_NODE_MAJOR} or newer`
  48. );
  49. });
  50. it('points users to Node 22 LTS via nvm and Homebrew', () => {
  51. const banner = buildNodeTooOldBanner('16.0.0');
  52. expect(banner).toContain('Node.js 22 LTS');
  53. expect(banner).toContain('nvm install 22');
  54. expect(banner).toContain('brew install node@22');
  55. });
  56. it('documents the CODEGRAPH_ALLOW_UNSAFE_NODE override', () => {
  57. expect(buildNodeTooOldBanner('18.0.0')).toContain('CODEGRAPH_ALLOW_UNSAFE_NODE=1');
  58. });
  59. });