Skip to content

Conversation

hitarth-gg
Copy link
Collaborator

Description of Change

  • Set up Vitest for testing
  • Added mocks for Electron modules
  • Added unit tests for src/index.ts
  • More tests will be added once this foundational PR for the testing setup is merged

@hitarth-gg hitarth-gg marked this pull request as ready for review August 25, 2025 18:57
@dsanders11
Copy link
Member

@hitarth-gg, did you want to move ahead with updating this PR after #279 was merged? I think it's still a good idea to explore migrating to Vitest, but understand if you want to close this for now and come back to it in the future. 👍

@hitarth-gg
Copy link
Collaborator Author

@dsanders11 I agree, It'd be nice to migrate to Vitest. Last week I actually tried using Vitest in the same way I use Mocha to test things in a real Electron app, but I couldn’t quite figure it out. I’ll need to dig a bit deeper into that.

College schedule is a bit busy this month since I’m preparing for exams, which will likely finish in the last week of September. If needed, we can close this PR for now, or keep it open (whichever is preferred) and I can come back at the beginning of October and continue working on it.

@dsanders11
Copy link
Member

@hitarth-gg, thanks for the update. I'll move it to draft state at the moment so it's clear it's still in-progress.

@dsanders11 dsanders11 marked this pull request as draft September 9, 2025 22:33
@hitarth-gg
Copy link
Collaborator Author

@dsanders11 I'm not really sure if Vitest can run tests in a real electron app like Mocha does, to test whether IPC events are correctly captured and received by Devtron Extension, since Vitest spawns its own process.

That said, Vitest can be used in combination with Mocha, where Mocha handles the in-Electron tests while Vitest is used for unit testing.

@erickzhao
Copy link
Member

@hitarth-gg IIRC @MarshallOfSound replaced electron-mocha with some custom Vitest code in electron/asar#371

@hitarth-gg
Copy link
Collaborator Author

@hitarth-gg IIRC @MarshallOfSound replaced electron-mocha with some custom Vitest code in electron/asar#371

Looked into that PR, and it seems the tests there don’t actually access any Electron APIs, probably because there's no need to. If I try to access electron APIs in those tests, anything imported from electron ends up being undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants