After much hacking, I've managed to get a simple Jasmine test running via Node.
However, there is some weird stuff I do not understand... The jasmine files export functions that appear to need a reference to themselves passed back in to work (this goes for both Jasmine and the ConsoleReporter).
I'm certain this isn't the correct way to do this (though I'm happy that I finally made some tests run :)), so can someone explain the better way to do this?
(Note: I'm not interested in pulling in more third party code I don't understand like node-jasmine; I want to understand what I had for now; not add more!)
// Include stuff
jasmine = require('../../../Apps/Jasmine/jasmine-standalone-2.0.0/lib/jasmine-2.0.0/jasmine.js');
jasmineConsole = require('../../../Apps/Jasmine/jasmine-standalone-2.0.0/lib/jasmine-2.0.0/console.js')
// WHAT THE? I DON'T EVEN KNOW WHAT THIS MEANS
jasmine = jasmine.core(jasmine);
jasmineConsole.console(jasmineConsole, jasmine)
// Set up the console logger
jasmine.getEnv().addReporter(new jasmine.ConsoleReporter({ print: console.log }));
// Create some global functions to avoid putting jasmine.getEnv() everywhere
describe = jasmine.getEnv().describe;
it = jasmine.getEnv().it;
expect = jasmine.getEnv().expect;
// Dummy tests
describe("A suite", function() {
it("contains spec with an expectation", function() {
expect(true).toBe(true);
});
it("contains spec with a failing expectation", function() {
expect(true).toBe(false);
});
});
// Kick off execution
jasmine.getEnv().execute();
Edit: Noticed this in the shipped bootstrap.js
, which is basically the same (other than different naming)... So maybe this is normal?!