Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start migration of tests to electron-mocha #1061

Merged

Conversation

araujoarthur0
Copy link
Collaborator

@araujoarthur0 araujoarthur0 commented Jan 30, 2024

Related issue

Helps #1037

Context / Background

Refer to #1054.
Here I'm starting to migrate our tests to the electron-mocha infrastructure, which works well with ES6 modules.
I think I'll only be able to pre-migrate the ones that don't depend on jest-specific things, before switching fully to ES6.
Starting with the simple test tests/main/time-math.js as an example here.

What change is being introduced by this PR?

  • Dependency changes
    • @babel/plugin-transform-modules-commonjs is used to convert ES6 into common js while we don't move fully to ES6.
    • electron-mocha and mocha will be the test runners we use
    • Added c8 dependency, which has the same purpose as nyc, that of a code coverage runner around mocha. Had to use this one because nyc doesn't work with electron-mocha. Anyway, c8 is considered the native replacement to nyc, and the output is exactly the same.
  • Added config files for electron-mocha. Some configs like color and parallel are to make the test runs better.
  • Added new npm target "test:electron-mocha-main", which is used in the test pipeline.
  • Migrated time-math.js test to use mocha.
    • Removed time-math.js from the jest matching tests, now that it's migrated.
    • Added it to electron-mocha-main.config.js

How will this be tested?

Pipeline passes in the same way, coverage will be coming from two reports and is currently being merged into a single report. CodeCov is properly parsing the combination.

Copy link

codecov bot commented Jan 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8f2ae80) 80.00% compared to head (9b9c47b) 81.37%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1061      +/-   ##
==========================================
+ Coverage   80.00%   81.37%   +1.37%     
==========================================
  Files          20       22       +2     
  Lines        1270     1401     +131     
  Branches      191      214      +23     
==========================================
+ Hits         1016     1140     +124     
- Misses        254      261       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@tupaschoal tupaschoal left a comment

Choose a reason for hiding this comment

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

Seems fine, actually easier than I thought, dependency changes aside, but I think that's because time-math has no stubs/mocks, right?

My comments are mostly just questions, so I'm hitting approve.

.github/workflows/Checks.yml Show resolved Hide resolved
.github/workflows/Checks.yml Outdated Show resolved Hide resolved
__tests__/__main__/time-math.js Show resolved Hide resolved
__tests__/electron-mocha-main.config.cjs Show resolved Hide resolved
@araujoarthur0
Copy link
Collaborator Author

Seems fine, actually easier than I thought, dependency changes aside, but I think that's because time-math has no stubs/mocks, right?

Yes, I chose the simplest one to get it along with the infrastructure changes 🤣

@araujoarthur0 araujoarthur0 merged commit b3fd77f into thamara:main Feb 3, 2024
9 checks passed
@araujoarthur0 araujoarthur0 deleted the start-electron-mocha-migration branch February 3, 2024 14:19
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