Has anyone else experienced that tests simply don’t show up in the testrunner, when hidden erros occur.
I am running my tests from within imports/modules/* and right now a lot of tests do not show up.
I am sure that I have an error somewhere in my code BUT I would still expect the testrunner to run all tests.
While happily using the mocha / chai guidance above, I was using the official chai documentation for guidance on supported asserts. So, I wrote some code using isAtLeast. I was very surprised to eventually figure out that the version of chai in practicalmeteor:mocha hasn’t been updated since the middle of last year and doesn’t support isAtLeast.
So, in keeping with new meteor 1.3 guidance, I’m happy to report that simply running meteor npm install chai, adding import { assert } from 'chai'; in the test file and removing the import for practicalmeteor:chai solved my problem!
Hopefully, we’ll see many of these modules that are simple wrappers around well-maintained npm modules rapidly disappearing over the next few weeks!
As testing and debug go hand-in-hand, perhaps the debug-port option to the meteor test command should be mentioned in this guide. Could be sleep deprivation, but it took me way too long to figure out that the server-side debugging I normally do using ‘meteor debug’ is available via the debug-port option when testing.
meteor test --debug-port 5858 --driver-package practicalmeteor:mocha
I attempted to install chimp per instructions: meteor npm install --global chimp. This install appears to fail for me because chimp has dependencies that require updated versions of node. Am I correct in assuming that chimp is not usable until this is resolved?
I have a 5.11 version of node on my machine and chimp can install in there. I have never used chimp before and I am not really clear on how it works. But I assume that it needs to be installed in the meteor version of node and I cannot use chimp installed in my version of node?
Related issues:
chimp #204: in the thread they advise updating the dev_bundle to a later release, I assume that would cause issues. They also refer to older versions of selinium, I don’t see any reference to selenium in my error output.
meteor #5124: Looks like node will start to get back on track sometime soon.
Environment:
Windows 10
Meteor v1.3.2.4
Error output:
npm WARN engine deep-extend@0.4.1: wanted: {"node":">=0.12.0","iojs":">=1.0.0"} (current: {"node":"0.10.43","npm":"2.14.22"})
npm WARN engine webdriverio@4.0.5: wanted: {"node":">= 0.12.0"} (current: {"node":"0.10.43","npm":"2.14.22"})
npm WARN optional dep failed, continuing fsevents@0.3.8
npm WARN engine is-buffer@1.1.3: wanted: {"node":">=0.12"} (current: {"node":"0.10.43","npm":"2.14.22"})
npm WARN deprecated graceful-fs@3.0.8: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
npm WARN deprecated jade@0.26.3: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated graceful-fs@2.0.3: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
\
\> fibers@1.0.10 install C:\Users\admin\AppData\Local\.meteor\packages\meteor-tool\1.3.2_4\mt-os.windows.x86_32\dev_bundle\bin\node_modules\chimp\node_modules\fibers
\> node build.js || nodejs build.js
C:\Users\admin\AppData\Local\.meteor\packages\meteor-tool\1.3.2_4\mt-os.windows.x86_32\dev_bundle\bin\node_modules\chimp\node_modules\fibers>if not defined npm_config_node_gyp (node "C:\Users\admin\AppData\Local\.meteor\packages\meteor-tool\1.3.2_4\mt-os.windows.x86_32\dev_bundle\lib\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild --release ) else (node "" rebuild --release )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: ImportError: No module named site
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:658:15)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at maybeClose (child_process.js:766:16)
gyp ERR! stack at Socket.<anonymous> (child_process.js:979:11)
gyp ERR! stack at Socket.emit (events.js:95:17)
gyp ERR! stack at Pipe.close (net.js:466:12)
gyp ERR! System Windows_NT 10.0.10240
gyp ERR! command "node" "C:\\Users\\admin\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.2_4\\mt-os.windows.x86_32\\dev_bundle\\lib\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd C:\Users\admin\AppData\Local\.meteor\packages\meteor-tool\1.3.2_4\mt-os.windows.x86_32\dev_bundle\bin\node_modules\chimp\node_modules\fibers
gyp ERR! node -v v0.10.43
gyp ERR! node-gyp -v v3.3.0
gyp ERR! not ok
Build failed
'nodejs' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\Users\\admin\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.2_4\\mt-os.windows.x86_32\\dev_bundle\\bin\\\\node.exe" "C:\\Users\\admin\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.2_4\\mt-os.windows.x86_32\\dev_bundle\\lib\\node_modules\\npm\\bin\\npm-cli.js" "install" "--global" "chimp"
npm ERR! node v0.10.43
npm ERR! npm v2.14.22
npm ERR! code ELIFECYCLE
npm ERR! fibers@1.0.10 install: `node build.js || nodejs build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fibers@1.0.10 install script 'node build.js || nodejs build.js'.
npm ERR! This is most likely a problem with the fibers package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node build.js || nodejs build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs fibers
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls fibers
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! e:\MERIS\npm-debug.log
I just noticed the use of arrow functions with describe and it in the guide. This is discouraged by mocha in calling these functions. See https://mochajs.org/#arrow-functions.
Thanks @tmeasday! I have chimp working fine against my running meteor instance. And I am starting to understand what chimp does ! I am pretty new to all of the web development and trying to assemble all the pieces has been challenging (in a good way).
I think the documentation should change from:
meteor npm install --global chimp
to:
npm install -g chimp
assuming there is a valid instance of node installed chimp works fine as you noted.
In the Mocking the database section, it says todo app has an internal package stub-collection.
It looks like they just changed to hwillson:stub-collections (right now package is 2 days old, and the change on meteor/todo 23hrs old).
Since I’ve lost some time to figure it out, I decided to drop a note, if not as a reminder to update the guides, at least some guidance for those searching for stub-collections while the guide is outdated.
PS: The Todo also change the import style and some of the api:
The API itself hasn’t changed (the same StubCollections functions are available), but the package has been updated to leverage ES2015 support (no more globals). If you notice any issues @fabs definitely let me know here. Thanks!
Sorry, I was not that precise. I think the code sample need some minor changes since the package is now out of the todo, and imported in a different way.
without the deconstruction and with the correct package name: import StubCollections from 'meteor/hwillson:stub-collections';
instead of : import { StubCollections } from 'meteor/stub-collections';
Also, I got a little confused with the .add() and .stub() [that made me think the API changed], so maybe it could read StubCollections.stub([Todos]) so I know I can pass a list of collections to be stubbed, or even: StubCollections.add([Todos]); StubCollections.stub();
I’m having same issue.
It’s true one can install chimp in whatever version of node.js, but chimp cannot be executed from meteor (for node version incompatibility mentioned above). That is, the command from the testing guide:
meteor npm run chimp-watch
cannot work because it uses meteor’s node which is (for what I know) 0.10, far behind chimp’s requirement (4+).
I’m resolving installing chimp with plain npm, as stated here, then running chimp from the command line, for example:
chimp --jasmine --path=tests
For me, the current testing guide is not working without these changes.
Let’s say I’m writing a unit test for a Blaze component based on the section A Simple Unit Test in the guide, using the withRenderedTemplate() helper from the test-helpers.js provided in that section.
Let’s also say my component has some internal state that I want to write an assertion against (the example test only shows how to write assertions against the rendered DOM result).
In other words, I’m trying to get a hold of the component’s state (or at least its Template instance) from the callback inside the withRenderedTemplate() helper.
I tried multiple different ways, including passing a callback that is called (using this.autorun()) whenever the internal state that I want to observe has changed.
For the sake of staying close to the example, let’s imagine I want to write a test in which I assert that onEditingChange() is actually called. So I want to trigger the 'focus event on the <input> and then ensure the callback is called.
How would I accomplish that?
EDIT: Here’s some code for what I am trying to accomplish:
it('calls onEditingChange when input is focused', function (done) {
const todo = Factory.build('todo');
const data = {
todo,
editing: true,
onEditingChange: (state) => {
// ensure `onEditingChange` is called
chai.assert.equal(state, true);
done();
},
};
withRenderedTemplate('Todos_item', data, el => {
// find input and place focus on it
$(el).find('input[type=text]').focus();
});
});
That looks conceptually pretty good. It’s not clear to me what’s going wrong. Is the callback ever called? Does this line of code run when you do $(..).focus()?