How can I use assert and Meteor globals in the same scope? #98

dandv opened this Issue Feb 20, 2014 · 2 comments

2 participants


I'm trying to use assert on the result of a function I define in server/myfunc.js. The problem is that in the scope in which myFunc is defined (server.eval()), assert is no longer defined:


suite('Posts', function() {
  test('in the server', function(done, server) {

    var assert = require('assert');
    server.eval(function() {
      assert.equal(myFunc(), 'foo');  // ReferenceError: assert is not defined
      Posts.insert({title: 'hello title'});
      var docs = Posts.find().fetch();
      emit('docs', docs);

    server.once('docs', function(docs) {
      assert.equal(docs.length, 1);

I presume that's because laika injects the test code into the server via a TCP connection, and the assert is completely out of scope.

How can I solve this problem?


I had read the docs and updated my GitHub issue text shortly after you got the email notification :)

I'm just trying to figure out the simplest way to get an assert of a server method running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment