Skip to content

Add test infrastructure for safe dependency updates#1

Merged
benfoxall merged 11 commits intomainfrom
copilot/add-tests-for-dependencies
Jan 19, 2026
Merged

Add test infrastructure for safe dependency updates#1
benfoxall merged 11 commits intomainfrom
copilot/add-tests-for-dependencies

Conversation

Copy link
Contributor

Copilot AI commented Jan 18, 2026

Add Test Infrastructure for Hex Viewer

  • Set up Vitest as the test framework (lightweight, fast, works well with modern JS)
  • Add @testing-library/react for React component testing
  • Create tests for utility functions in util.js
    • Test ByteSize component
    • Test useObjectURL hook behavior
    • Test useMedia hook behavior
  • Create tests for Hex component logic
    • Test HexPairs formatting
    • Test Ascii conversion
    • Test row address formatting
  • Add integration tests for App component
    • Test file drop functionality and hex content display
    • Test hex viewer rendering
    • Test ASCII representation
    • Test file close functionality
    • Test postMessage integration for cross-window communication
    • Test download link generation
    • Test empty file handling
    • Test initial state rendering
    • Test drag active state
  • Update package.json test script
  • Add test configuration (vitest.config.js)
  • Run tests to verify they pass (32 tests passing - 23 unit + 9 integration)
  • Verify tests catch regression when dependencies are updated
  • Update README with test instructions
  • Address code review feedback
  • Add GitHub workflow to run tests on every PR
  • Add TODO comment for future test improvements
  • Fix ES module error by adding type: module to package.json
  • Rename config files to .cjs for CommonJS compatibility
  • Exclude test files from Snowpack build to prevent dependency conflicts
  • Add blob.arrayBuffer() polyfill for jsdom compatibility
  • Improve test code quality with error handling and helper functions
  • Fix CI test failures by switching from jsdom to happy-dom
Original prompt

Add some tests for this project. The goal is to allow me to update dependencies and know that I haven't broken stuff.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 18, 2026 21:15
Co-authored-by: benfoxall <51385+benfoxall@users.noreply.github.com>
Co-authored-by: benfoxall <51385+benfoxall@users.noreply.github.com>
Co-authored-by: benfoxall <51385+benfoxall@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests to validate project functionality during dependency updates Add test infrastructure for safe dependency updates Jan 18, 2026
Copilot AI requested a review from benfoxall January 18, 2026 21:20
@benfoxall
Copy link
Owner

@copilot Could you add a github workflow file to run the tests on every pr

Co-authored-by: benfoxall <51385+benfoxall@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 18, 2026

@copilot Could you add a github workflow file to run the tests on every pr

Added in df708ad. The workflow will run tests on every PR and push to main using npm test.

Co-authored-by: benfoxall <51385+benfoxall@users.noreply.github.com>
@benfoxall
Copy link
Owner

@copilot The tests seem to be failing because of a missing package type.

Could you look at the failure and try and correct the error?

Co-authored-by: benfoxall <51385+benfoxall@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 19, 2026

@copilot The tests seem to be failing because of a missing package type.

Could you look at the failure and try and correct the error?

Fixed in 73567a7. The issue was that Vite/Vitest v7.x are ES modules only and require "type": "module" in package.json. Tests now pass successfully.

Co-authored-by: benfoxall <51385+benfoxall@users.noreply.github.com>
@benfoxall
Copy link
Owner

@copilot I think this is missing some higher level tests – like "can I drop a file in the window and see the hex contents of it"

Co-authored-by: benfoxall <51385+benfoxall@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 19, 2026

@copilot I think this is missing some higher level tests – like "can I drop a file in the window and see the hex contents of it"

Added in 5af714c. Created 9 integration tests in App.test.jsx that test the complete user workflow:

  • File drop functionality
  • Hex content rendering after file drop
  • ASCII representation display
  • File close functionality
  • PostMessage integration
  • Download link functionality
  • Empty file handling

All 32 tests now pass (23 unit tests + 9 integration tests).

Co-authored-by: benfoxall <51385+benfoxall@users.noreply.github.com>
Copy link
Owner

@benfoxall benfoxall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@benfoxall benfoxall marked this pull request as ready for review January 19, 2026 19:07
@benfoxall
Copy link
Owner

@copilot looks like the tests are failing 🤔

Co-authored-by: benfoxall <51385+benfoxall@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 19, 2026

@copilot looks like the tests are failing 🤔

Fixed in 5e5c410. The issue was that jsdom v27.x has a dependency (@exodus/bytes) that's an ES module, which conflicts with the "type": "module" setting in package.json. Switched to happy-dom which is fully compatible with ES modules. All 32 tests now pass in CI.

@benfoxall benfoxall merged commit ba844cf into main Jan 19, 2026
1 check passed
@benfoxall benfoxall deleted the copilot/add-tests-for-dependencies branch January 19, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants