Jhernandez has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/335425 )
Change subject: WIP: Set up qunit running in node to migrate tests
......................................................................
WIP: Set up qunit running in node to migrate tests
In order to run qunit tests on sources that use common.js modules, set
up infra to run qunit tests in the node cli when running `npm run
test:node`.
Changes:
* Add npm script test:node that runs the tests
* Run node tests on CI (npm test)
* Add a qunit node test runner in scripts/qunit-node-runner.js
* Bring in QUnit, the tap logger and reporter, and sinon as npm
dependencies
Change-Id: I55d76b7db168f3745e0ac69852c152322ab385c3
---
M package.json
A scripts/qunit-node-runner.js
A tests/node-qunit/nested/t2.js
A tests/node-qunit/t1.js
4 files changed, 34 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups
refs/changes/25/335425/1
diff --git a/package.json b/package.json
index bb5e6f1..979fdae 100644
--- a/package.json
+++ b/package.json
@@ -2,6 +2,7 @@
"private": true,
"scripts": {
"test": "grunt lint",
+ "test:node": "node scripts/qunit-node-runner.js tests/node-qunit/*.js
tests/node-qunit/**/*.js | tap-spec",
"doc": "jsduck"
},
"devDependencies": {
@@ -14,6 +15,10 @@
"grunt-eslint": "19.0.0",
"grunt-jsonlint": "1.1.0",
"grunt-stylelint": "^0.6.0",
- "stylelint-config-wikimedia": "0.3.0"
+ "qunit-tap": "^1.5.1",
+ "qunitjs": "^2.1.1",
+ "sinon": "^1.17.7",
+ "stylelint-config-wikimedia": "0.3.0",
+ "tap-spec": "^4.1.1"
}
}
diff --git a/scripts/qunit-node-runner.js b/scripts/qunit-node-runner.js
new file mode 100644
index 0000000..6eefacd
--- /dev/null
+++ b/scripts/qunit-node-runner.js
@@ -0,0 +1,11 @@
+var path = require( 'path' );
+var Q = require( 'qunitjs' );
+var reporter = require( 'qunit-tap' );
+
+reporter( Q, function() { console.log.apply( console, arguments ); } );
+
+process.argv.slice( 2 ).forEach( function ( file ) {
+ require( path.resolve( file ) );
+} );
+
+Q.start();
diff --git a/tests/node-qunit/nested/t2.js b/tests/node-qunit/nested/t2.js
new file mode 100644
index 0000000..c243916
--- /dev/null
+++ b/tests/node-qunit/nested/t2.js
@@ -0,0 +1,7 @@
+var Q = require( 'qunitjs' );
+
+Q.module( 'nested module' );
+
+Q.test( 'tests on nested modules run', function ( assert ) {
+ assert.ok( true, 'test ran' );
+} );
diff --git a/tests/node-qunit/t1.js b/tests/node-qunit/t1.js
new file mode 100644
index 0000000..7826163
--- /dev/null
+++ b/tests/node-qunit/t1.js
@@ -0,0 +1,10 @@
+var Q = require( 'qunitjs' );
+var sinon = require( 'sinon' );
+
+Q.module( 'Basic qunit and sinon running in node' );
+
+Q.test( 'Qunit and sinon work in node', function ( assert ) {
+ var s = sinon.spy();
+ s();
+ assert.ok( s.called );
+} );
--
To view, visit https://gerrit.wikimedia.org/r/335425
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I55d76b7db168f3745e0ac69852c152322ab385c3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: mpga
Gerrit-Owner: Jhernandez <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits