-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add qunit tests (including cli runner with code coverage)
Test Plan: - Load in your LocalSettings with `wfLoadExtension( 'examples/Example' );`. - Confirm that with $wgEnableJavaScriptTest = true, the qunit tests run from Special:JavaScriptTest. - Confirm that in examples/Example, 'npm it' runs the qunit tests, with coverage report in standard out, and 'coverage/index.html' existing (can be viewed in a browser, e.g. with the 'open' command). Change-Id: I0b8b010c6dc030f77f0d92cb430f9bcea9c708ad
- Loading branch information
Showing
9 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
/composer.lock | ||
/vendor/ | ||
/node_modules/ | ||
/package-lock.json | ||
.nyc_output/ | ||
coverage/ | ||
node_modules/ | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"private": true, | ||
"@script.test": "TODO: remove spawn-wrap workaround after <https://gerrit.wikimedia.org/r/482527>", | ||
"scripts": { | ||
"test": "SPAWN_WRAP_SHIM_ROOT=. NODE_PATH=modules nyc qunit --require ./tests/bootstrap.js tests/qunit", | ||
"unit:watch": "NODE_PATH=modules qunit --watch --require ./tests/bootstrap.js tests/qunit" | ||
}, | ||
"devDependencies": { | ||
"nyc": "13.1.0", | ||
"qunit": "2.8.0" | ||
}, | ||
"nyc": { | ||
"exclude": [ | ||
"tests" | ||
], | ||
"reporter": [ | ||
"text", | ||
"clover", | ||
"html" | ||
], | ||
"report-dir": "../coverage" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* eslint-env node */ | ||
|
||
global.mw = { | ||
config: { | ||
values: {}, | ||
get: function ( key ) { | ||
return this.values[ key ]; | ||
} | ||
} | ||
}; | ||
|
||
// global.sinon = require( 'sinon' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "wikimedia/qunit" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
QUnit.module( 'ext.Example.welcome', { | ||
beforeEach: function () { | ||
this.conf = mw.config.values; | ||
mw.config.values = { | ||
wgExampleWelcomeColorDays: { | ||
tuesday: 'pink' | ||
}, | ||
wgExampleWelcomeColorDefault: '#ccc' | ||
}; | ||
}, | ||
afterEach: function () { | ||
mw.config.values = this.conf; | ||
} | ||
} ); | ||
|
||
QUnit.test( 'getColorByDate()', function ( assert ) { | ||
var welcome = require( 'ext.Example.welcome' ); | ||
assert.strictEqual( welcome.getColorByDate( 'monday' ), '#ccc', 'default' ); | ||
assert.strictEqual( welcome.getColorByDate( 'tuesday' ), 'pink', 'custom' ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters