Page MenuHomePhabricator

Create unit tests for CodeMirror
Closed, ResolvedPublic8 Estimated Story Points

Description

It would be good to make CodeMirror more testable and add some tests, possibly using QUnit for unit tests.

Event Timeline

Niharika triaged this task as Medium priority.Nov 7 2017, 11:53 PM
TBolliger renamed this task from Create tests for CodeMirror to Create unit tests for CodeMirror.Mar 7 2018, 12:12 AM
TBolliger updated the task description. (Show Details)
TBolliger set the point value for this task to 8.

If unit tests are turning out to be hard (T179534#4048202), we should at minimum do some integration tests. I know breaking that code apart is not easy.

Maybe you mean acceptance tests? Those I think will be even harder... unless some wants to give me the rundown of the MediaWiki-way of doing it. Acceptance tests are nice because they can do some cross-browser testing, but from my experience they are slow and fragile. Here the "stream" and colouring is specified in markup produced by all those functions, so unit tests seem quite fitting.

No one has worked with QUnit? Maybe I could poke the VisualEditor folks for help.

Maybe you mean acceptance tests? Those I think will be even harder... unless some wants to give me the rundown of the MediaWiki-way of doing it. Acceptance tests are nice because they can do some cross-browser testing, but from my experience they are slow and fragile. Here the "stream" and colouring is specified in markup produced by all those functions, so unit tests seem quite fitting.

No one has worked with QUnit? Maybe I could poke the VisualEditor folks for help.

Uh, I mean testing the entire module. Supplied x, Expected y and so on.

Pinging @Esanders in case he's got any pointers for us.

Uh, I mean testing the entire module. Supplied x, Expected y and so on.

That sounds pretty great, and perhaps better! But dunno how to do that either :(

I assume it's all with QUnit, which brings me to my question for Ed -- How do you get Special:JavascriptTests to run tests within an extension? I have VisualEditor installed and it's not running those tests, either. Hard to diagnose over Phabricator, I'm sure, but maybe you know of some better how-to guides than Manual:JavaScript unit testing, or a guide specifically for doing this in extensions?

Got it to work! \o/ There was a typo :) I'm not sure why the VE tests aren't running, but I'm not going to worry about it. Thanks anyway!

Change 419513 had a related patch set uploaded (by MusikAnimal; owner: MusikAnimal):
[mediawiki/extensions/CodeMirror@master] [WIP] (not ready for merge) One passing test!

https://gerrit.wikimedia.org/r/419513

See the patch for the test cases I've added. That should cover all the highlighting tickets at MediaWiki-extensions-CodeMirror, along with some other basics.

Change 420833 had a related patch set uploaded (by MusikAnimal; owner: MusikAnimal):
[integration/config@master] Add QUnit to CodeMirror

https://gerrit.wikimedia.org/r/420833

Change 420833 merged by jenkins-bot:
[integration/config@master] Add QUnit to CodeMirror

https://gerrit.wikimedia.org/r/420833

Change 419513 merged by jenkins-bot:
[mediawiki/extensions/CodeMirror@master] Tests for MediaWiki CodeMirror syntax highlighting

https://gerrit.wikimedia.org/r/419513