Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9089629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:11:44+00:00 2026-06-16T22:11:44+00:00

I’ve been playing with Meteor (and Meteorite) for a bit and love the ease

  • 0

I’ve been playing with Meteor (and Meteorite) for a bit and love the ease in which I got things up and running. Now I’d like to add some tests to the app and found that the main hurdle was including references/requires to packages used by Meteor in the test scripts.

As an example, I have a simple class that I wrote which internally uses some underscore methods. Then I wrote a simple mocha script to test it.

When I run

mocha my_test.js

it complains that _ is undefined. If I add

var _ = require('underscore')._

to my test code, it can’t find the underscore library because the packages are all wrapped up in a tight little bundle which is not on the NODE_PATH for mocha. I could specify that path, but that kind of hard-coded path seems like a bad idea.

Is there a way to run a node process/script (like mocha) in the Meteor environment? I’m looking for something similar to ‘bundle exec’ from ruby-land. I’ve looked into Meteorite and it seems to pretty much pass commands right down to Meteor so I was hoping you guys might want to field this one.

UPDATE:

After writing this, I started looking at the meteor source code. I was able to write up something that does mostly what I want and thought the Meteor team might comment on whether or not this seems like a good path to go down. Starting with the meteor shell script (/usr/local/meteor/bin/meteor), I added a case statement at the bottom that switches modes based on the command name. This file can replace the current meteor startup script and then you add a link from meteor-exec to meteor and voila. With this replacement script, I can run meteor in the normal fashion. I can also run

meteor-exec `which mocha` tests/mocha_test.coffee --compilers coffee:coffee-script

And I get the results I expect. I can require(‘underscore’) which is pulled from the third party libraries from Meteor. And I can include ‘mocha’ and ‘chai’ which are in my npm global package space.

If this appears to be of the right mindset, and the code agrees with the way you guys might proceed, I can submit a proper pull request.

The replacement meteor shell script is in this gist https://gist.github.com/4416913. I’ve added the diff below.

Thanks, in advance

Mr Rogers

ps. keep up the good work. I’m really loving Meteor.

diff meteor meteor.orig 
105,116c105,106
< NPM_GLOBAL_PATH=$(npm root -g)
< METEOR_THIRD_PARTY="$DEV_BUNDLE/app/lib/third"
< case $(basename $0) in
<   meteor)
<     export NODE_PATH="$DEV_BUNDLE/lib/node_modules"
<     exec "$DEV_BUNDLE/bin/node" "$METEOR" "$@"
<     ;;
<   meteor-exec)
<     export NODE_PATH="$DEV_BUNDLE/lib/node_modules:$METEOR_THIRD_PARTY:$DEV_BUNDLE/packages:$NPM_GLOBAL_PATH"
<     exec "$DEV_BUNDLE/bin/node" "$@"
<     ;;
< esac
---
> export NODE_PATH="$DEV_BUNDLE/lib/node_modules"
> exec "$DEV_BUNDLE/bin/node" "$METEOR" "$@"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:11:46+00:00Added an answer on June 16, 2026 at 10:11 pm

    You’re right that this gives you access to underscore and the node modules but as you said, you won’t be able to access meteor packages this way (ie you won’t be able to use Meteor.Collection). Also worth pointing out that admin/node.sh in our Git repository does the same thing as your meteor-exec.

    If you want to try to build a more complete solution, take a look at app/server/server.js to see how we load packages. You’ll need to do something like this to be able to test code that relies on Meteor itself. An alternative would be to create a smart-package wrapping mocha. There is currently no easy way to depend on NPM modules directly from Meteor packages (this is in the works), but you can just copy over the mocha source into your package. Then you could get to a point where just running meteor within your app runs your mocha tests (albeit while still running a web server listening on port 3000, etc)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.