Jasmine - node - including assistant

I am trying to test a Meteor application with jasmine-node . I skipped some methods of the Meteor structure in the helper ( spec_helper.js ):

  var Meteor = {
    startup: function (newStartupFunction) {
        Meteor.startup = newStartupFunction;
    },
    Collection: function (collectionName) {
        Meteor.instantiationCounts[collectionName] = Meteor.instantiationCounts[collectionName] ?
            Meteor.instantiationCounts[collectionName] + 1 : 1;
    },
    instantiationCounts: {}
  };

At this point, I need to run the code in spec_helper.js (something equivalent to including the module in other languages). I tried the following but did not succeed:

require(['spec_helper'], function (helper) {
    console.log(helper); // undefined
    describe('Testing', function () {
        it('should test Meteor', function () {
            // that what I want to call from my stubs... 
            // ...it obviously undefined
            Meteor.startup();
        });
    });
});

Any help would be greatly appreciated.

+4
source share
1 answer

jasmine_nodewill autoload helpers (any file containing a word helpers) from your specs directory.

: helper, helpers... , ... .

specs/unit, specs/unit/meteor-helper.js, jasmine_node . .js, JavaScript. --coffee grunt ( gulp, ), js|coffee|litcoffee.

hash :

specs/unit/meteor-helper.js

// file name must contain the word helper // x-helper is the convention I roll with module.exports = { key: 'value', Meteor: {} }

jasmine_node .

key Meteor ( , lib, ).

, jasmine_node --nohelpers (. README ).

node. /, jasmine.yml; spec_helper.js. , , node.

:. , jasmine-node , helpers. x-helper.js|coffee|litcofee . .. meteor-helper.coffee.

+9

Source: https://habr.com/ru/post/1527616/


All Articles