I have some .js files with source code used in my project, placed in:
projectroot/static/
I have test suite which uses QUnit, now there are only some dummy tests.
projectroot/js_tests/tests.js
if (typeof QUnit == 'undefined') // if your tests also run in the browser...
QUnit = require('qunit-cli');
QUnit.test("hello test", function (assert) {
assert.ok(1 == "1", "Passed!");
});
QUnit.test("hello error", function (assert) {
assert.ok(1 == "2", "Failed!");
});
I try to use QUnit-cli to run these tests from command line , in order to use suite every time I run server, commit etc (qunit-cli is installed globally).
qunit-cli js_tests/tests.js
And it works:
And now I would like to test all functions from source files in that test suite.
So I assume, that I have to somehow "include" them.
I've tried to add something like that:
addingMap = require('projectroot/static/adding-map.js');
QUnit.test("setMark", function (assert) {
var base = {top : 35, left : 55};
var mark1 = {};
var mark2 = {};
addingMap.placeMarks(base,mark1,mark2);
assert.ok(mark1.top == "40", "Success, tops equal!");
});
But it doesn't work. I think that i get it wrong.
Is there any easy , maybe special way to add source files to testsuite, different than in JS including question? Or maybe I should use one of ways provided in that thread?
Aucun commentaire:
Enregistrer un commentaire