-
Where to place
tests
folder andnpm
packages in Meteor folder structure so that they won't run withmeteor
command. -
How to access Meteor global variable and Meteor Collections.
-
How to run tests?
-
Where to place tests?
Run tests from Meteor only
Put
node_module
withintern
already installed undertests
folder.tests
folder is immune to meteor, it won't get executed when you run your meteor project.Folder Structure should be like this:
tests/ node_module/ intern tests/ functional/ index.js
Or
Don't put
npm
in Meteor package. Make a separate folder structure outside the Meteor project folder as a separate project.TheIntern only needs a URL and you can run that URL from anywhere. Even you can test Facebook.com without having its code using it.
-
Access Meteor global variable and Collections
We have
execute
function in which we can run any JS code. Bingoooooo!!!!!! We can access Browserswindow
variable andMeteor
as well. -
How to run tests.
If you are running tests from Meteor only
cd tests node node_modules/.bin/intern-runner config=intern
Or
In same way as normal TheIntern.io's test suites run.
Sample code:
Using execute
method
For more details on execute
function: click here
define(function (require) {
var registerSuite = require('intern!object');
var assert = require('intern/chai!assert');
registerSuite({
name: 'index',
'greeting form': function () {
var rem = this.remote;
return this.remote
.get(require.toUrl('localhost:3000'))
.setFindTimeout(5000)
.execute(function() {
console.log("browser window object", window)
return Products.find({}).fetch().length
})
.then(function (text) {
console.log(text)
assert.strictEqual(text, 2,
'Yes I can access Meteor and its Collections');
});
}
});
});