Skip to content

Deprecate ember-mocha - #858

Merged
wagenet merged 2 commits into
emberjs:masterfrom
bertdeblock:deprecate-ember-mocha
Mar 10, 2023
Merged

wagenet merged 2 commits into
emberjs:masterfrom
bertdeblock:deprecate-ember-mocha

Conversation

@bertdeblock

@bertdeblock bertdeblock commented Nov 8, 2022 •

Copy link
Copy Markdown
Member

@bertdeblock bertdeblock self-assigned this Nov 8, 2022
@bertdeblock bertdeblock added T-ember-data RFCs that impact the ember-data library T-framework RFCs that impact the ember.js library T-learning labels Nov 8, 2022
@bertdeblock
bertdeblock force-pushed the deprecate-ember-mocha branch from caa31f9 to 05400ed Compare November 8, 2022 19:29
@jrjohnson

Copy link
Copy Markdown
Contributor

This biggest motivation for me in this change would be removing a confusing branching decision when creating a new ember project. Should I use Mocha? Is it better? What are the pros and cons vs qunit? Are all questions caused by the presence of both of these official testing libs. Removing ember-mocha saves developers from a wheel spinning annoyance very early in their ember experience.

@wagenet wagenet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems straightforward to me. We should discuss it at this week's meeting.


## Drawbacks

People using `ember-mocha` will have to migrate to using `ember-qunit` instead

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

They'll have to migrate anyway unless someone starts maintaining it, and it doesn't sound like people are leaping at that chance.

@octo-topi octo-topi Nov 25, 2022 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We successfully migrate a bunch (10kloc) of code from Mocha to QUunit using this codemod
https://github.com/1024pix/ember-freshdesk-codemods

The PR is in french though
1024pix/pix#5258

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is great, thanks for sharing @octo-topi!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@octo-topi I was amazed by the quality of your pull request. Texts can be auto-translated, no worries.

I think the one-to-one mapping between assertions in mocha and qunit, shown in commit 3, will help other teams with their migration. 💯

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well, @VincentHardouin is actually the one who has the job done, helped by several other members.
As we have an open-source repository, it was worth share the result so other people can focus on less tedious task.

@bertdeblock
bertdeblock force-pushed the deprecate-ember-mocha branch from 05400ed to b70fa32 Compare November 9, 2022 07:27
@ijlee2

ijlee2 commented Nov 9, 2022 •

Copy link
Copy Markdown
Member

I'm in favor of deprecating ember-mocha for a few reasons:

  • We help different Ember projects converge to a standard. When there is a problem with testing, solutions may be easier to share when there is common ground.
  • We help simplify Ember.js code, as described in the proposal.
  • We don't necessitate work on addon authors for a feature parity. For example, ember-exam has a few features that are not supported in Mocha. Another example is Mirage logging from ember-cli-mirage.

I imagine, how easily one can migrate from Mocha to QUnit partly depends on if the test suite had been well-maintained (i.e. the experience will be different from one team to another). The mocha-to-qunit codemod might help with the migration.

@bertdeblock

bertdeblock commented Nov 9, 2022 •

Copy link
Copy Markdown
Member Author

Thanks @jrjohnson and @ijlee2 for your feedback, I'll make sure to incorporate it into the RFC.

@joegaudet

joegaudet commented Nov 18, 2022 •

Copy link
Copy Markdown

Will there be code mods or other tools built to help those that have built code on ember-mocha? I believe Tom assured us that ember was a big tent when it came to testing?

@joegaudet

Copy link
Copy Markdown

(Also I prefer BDD style :P)

@bertdeblock

Copy link
Copy Markdown
Member Author

The mocha-to-qunit codemod was already suggested here, so maybe that's an option?

@ijlee2

ijlee2 commented Nov 18, 2022 •

Copy link
Copy Markdown
Member

@joegaudet @bertdeblock

I do think it's unfortunate that there aren't many learning resources, to help teams see how to incrementally migrate a (large) test suite.

I found these links today:

The Medium article mentions an in-repo addon that had allowed the team to run Mocha and QUnit side-by-side, but I wasn't able to find the addon if it had been open-sourced. @bertdeblock, maybe you could reach out to the author?

In theory, one would first run ember-mocha-codemods to migrate to recommended testing patterns in Ember v3, then mocha-to-qunit. Everything just works.

In practice, a more effective strategy may be to turn off Mocha completely:

  1. If tests are run in continuous integration, temporarily set the test script in package.json to exit 0 (unconditional success).

  2. Uninstall ember-mocha and related packages. Install instead ember-qunit, eslint-plugin-qunit, qunit, and qunit-dom (refer to the Ember blueprint for package.json). Update .eslintrc.js and tests/test-helper.js. For a sanity check, visit localhost:4200/tests.

  3. Introduce default tests in tests/integration and tests/unit, for every file that is important, e.g. components, routes, etc. Default tests are ones that Ember CLI creates when you run ember g component-test ..., ember g route-test ..., etc. They often include a tautology such as assert.ok(true);. The default tests guarantee that files can be read in tests and running their code doesn't cause an error.

  4. Update the test script to run tests in continuous integration.

  5. Re-introduce the tests that had been written in Mocha.

Each step corresponds to a separate pull request. Steps 3 and 5 could be split into multiple tasks so that a team of people can work on them in parallel, without running into merge conflicts.

@joegaudet

joegaudet commented Nov 18, 2022 via email

Copy link
Copy Markdown

@wagenet

wagenet commented Nov 20, 2022

Copy link
Copy Markdown
Member

@joegaudet I don't think anyone is opposed to ember-mocha in concept, but the fact of the matter is that it's unmaintained and no one is stepping up to maintain it. At this point, it's better for us to say it's deprecated instead of acting like it's a viable option for people getting started.

I'm strongly opposed to just moving it into adopted addons unless we at least have someone who will make it compatible with Ember 4. To do so now would imply that it has support that it just doesn't have.

I don't love this outcome, but I'd prefer to at least be honest about where things stand.

@wagenet

wagenet commented Nov 20, 2022 •

Copy link
Copy Markdown
Member

@joegaudet also, don't be so sure to assume the work is out of your pay grade. A lot of this stuff just ends up being a matter of getting your hands dirty and pushing through. If you do want to do the work and the only thing stopping you is feeling unqualified, let's see if we can help get you moving. Everyone starts somewhere!

@joegaudet

joegaudet commented Nov 22, 2022 via email

Copy link
Copy Markdown

@joegaudet

joegaudet commented Nov 22, 2022 via email

Copy link
Copy Markdown

@wagenet

wagenet commented Nov 23, 2022

Copy link
Copy Markdown
Member

@joegaudet I should have realized the name was familiar! It sounds like ember-mocha doesn't even support Ember 4 yet, so that would be a good start.

@yads

yads commented Nov 29, 2022 •

Copy link
Copy Markdown

FYI, for everyone who is looking to migrate away from ember-mocha, here's a codemod to update your test files. I've already used this to migrate a project I maintain, it was fairly painless.
https://github.com/yads/ember-mocha-to-qunit-codemod

For context I was a maintainer of my own fork of ember-mocha, but could not get it upgraded to Ember 4, as such I decided to abandon ship.

@wagenet wagenet added the S-Proposed In the Proposed Stage label Dec 2, 2022
@apellerano-pw

Copy link
Copy Markdown

I had tried a couple years back on my personal acct to bump the mocha major version in ember-mocha, but it reached a point where a breaking change felt inevitable.

I think this is the situation causing ember-mocha's disrepair:

  1. It has to navigate a very long mocha upgrade path,
    • which itself has breaking changes;
    • at least one of which directly violates ember-mocha's current architecture.
  2. You have to understand the separation of responsibilities across ember-cli, ember-test-helpers, and ember-mocha.
  3. You have to understand the broccoli->embroider transition.
  4. Your project had to consciously shun qunit at some point which has default option momentum in both ember-cli and ember documentation.

Anyone who steps up to lead ember-mocha is going to break someone else's tests. They also need a really solid understanding of Ember ecosystem plumbing. And lastly they had to opt-in to mocha in the first place (to have some skin in the game.) I think this basically brings the set of possible maintainers to near-zero.

Could anyone spell out what ember-mocha maintainership would even look like? Like what is the role of ember-mocha in the big picture, and how small of a lib should it be to accomplish its goals? Assuming you had to build it from scratch today (which is basically what we need) what would you be signing up to build?

@wagenet wagenet added Final Comment Period S-Exploring In the Exploring RFC Stage and removed S-Proposed In the Proposed Stage Final Comment Period labels Jan 27, 2023
@wagenet

wagenet commented Jan 27, 2023

Copy link
Copy Markdown
Member

I think we want to do everything in this RFC except actually deprecate the library. We should, however, move it out of the main Ember org and make it clear that it does not support Ember v4 at the moment. If we can establish a new maintainer there's no reason that it can't continue to be used going forwards.

@bertdeblock

Copy link
Copy Markdown
Member Author

Will try to update the wording soon.

@bertdeblock

Copy link
Copy Markdown
Member Author

Anyone following along who is interested in taking over maintenance? Should we ask on Discord as well?

@wagenet

wagenet commented Feb 17, 2023

Copy link
Copy Markdown
Member

@bertdeblock it's seeming like nobody actively wants to take over. We should move forward assuming that there won't be anyone.

@wagenet wagenet closed this Feb 17, 2023
@wagenet wagenet reopened this Feb 17, 2023
@bertdeblock
bertdeblock force-pushed the deprecate-ember-mocha branch 3 times, most recently from 4ab1ac2 to 25d56f5 Compare February 19, 2023 09:43
@bertdeblock
bertdeblock force-pushed the deprecate-ember-mocha branch from 25d56f5 to c9679ba Compare February 19, 2023 09:53
@bertdeblock

Copy link
Copy Markdown
Member Author

Updated the RFC a bit, based on some of the comments on this PR.

@kategengler

Copy link
Copy Markdown
Member

The framework team gave this a final review today and we've decided to put it in final comment period for the Accepted stage.

@wagenet
wagenet enabled auto-merge March 10, 2023 19:52
@wagenet
wagenet merged commit 8010551 into emberjs:master Mar 10, 2023
ef4 added a commit that referenced this pull request Sep 8, 2023
Advance RFC #858 `"Deprecate ember-mocha"` to Stage Ready for Release
ef4 added a commit that referenced this pull request Sep 15, 2023
Advance RFC #858 `"Deprecate ember-mocha"` to Stage Released
ef4 added a commit that referenced this pull request Oct 13, 2023
Advance RFC #858 `"Deprecate ember-mocha"` to Stage Recommended
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Final Comment Period S-Exploring In the Exploring RFC Stage T-ember-data RFCs that impact the ember-data library T-framework RFCs that impact the ember.js library T-learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants