-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require failure using wallaby_server with wallaby and coffeescript #52
Comments
This is indeed a limitation of the current implementation. I think a reasonable solution would be to make the Node.js require aware of the Meteor packages by adding them to E.g.
|
Seemed like a good suggestion except it doesn't work because the cache key is the resolved filename not the string identifying the module. At the moment I am going to try overriding or replacing 'require' with one that uses meteorRequire directly when possible. |
Another approach would be to use proxyquire in the test files: const meteorRequire = meteorInstall();
const proxyquire = require('proxyquire');
const stubs = {
// meteor/meteor is not available in our testing environment, so we need `'@noCallThru': true`
'@noCallThru': true,
'meteor/meteor': meteorRequire('meteor/meteor')
};
proxyquire('./unit_under_test', stubs); And yet another approach maybe is to load the app files that were compiled by the Meteor build tool by removing https://github.com/xolvio/automated-testing-best-practices/blob/master/wallaby_server.js#L235-L238 and using meteorRequire in your tests. const meteorRequire = meteorInstall();
const unitUnderTest = meteorRequire('./unit_under_test'); |
Thanks for the suggestions. I ended up going with a solution that replaced the use of require for all non-relative-path require statements with a function from an imported module at the root of the app that conditionally used meteorRequire, not ideal but solved a couple of require related challenges and is a fairly easy search and replace refactor if and when possible. This worked well until trying to execute tests that involved running code from the meteor packages (the primary goal) which resulted in: Is it correct and necessary to call Meteor.bindEnvironment for every describe / it / before block and if so will this also work when running under meteor test? Am I missing something else, like is there a way/need to tell wallaby to use the dispatch:mocha-phantomjs installation rather than its own mocha? |
I'm trying to get wallaby working for server tests for a meteor app that uses coffeescript. So I tried to use the wallaby_server file from this repo however it fails because it can't find any meteor modules/packages. It also fails to load local modules referenced by absolute path or with the extension '.coffee'. The last is totally acceptable and the requirement for relative paths is manageable if necessary but obviously the failure to load meteor packages is a show stopper.
Sample project demonstrating the issue: https://github.com/jdrucza/coffee-wallaby
NOTE: I renamed the wallaby_server.js to '.wallaby_server.js' (i.e. starting with a '.') so it would not be picked up by meteor.
Probably obvious but for completeness/search-aid the error is:
I suspect the issue may be that wallaby needs to be configured to use meteor's coffeescript rather than its in-built version but I've no idea how to make this happen.
The text was updated successfully, but these errors were encountered: