{"__v":33,"_id":"5604378e8d58900d0051eaea","category":{"__v":8,"_id":"55a4bcf31a5f991700a94066","pages":["55a4bd121a5f991700a94067","5601ea8ffb9f160d00f2988c","5604378e8d58900d0051eaea","56043ac38d58900d0051eaf6","56043ade0c78b00d0039b16b","56057354e266000d00897239","560573a17c8e580d0001b05c","566c957d9aa84517001b4fb8"],"project":"559b65bd8b04e90d00702d54","version":"559b65bd8b04e90d00702d57","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-07-14T07:40:35.019Z","from_sync":false,"order":1,"slug":"meteor","title":"Meteor"},"parentDoc":null,"project":"559b65bd8b04e90d00702d54","user":"559b658d8b04e90d00702d52","version":{"__v":6,"_id":"559b65bd8b04e90d00702d57","project":"559b65bd8b04e90d00702d54","createdAt":"2015-07-07T05:38:05.890Z","releaseDate":"2015-07-07T05:38:05.890Z","categories":["559b65be8b04e90d00702d58","55a46e7468c7e20d0036d4d1","55a4971be6c2470d002a6483","55a4a690e10ba50d00b40bba","55a4bcf31a5f991700a94066","56cf5c8d336aa60b0086a40d"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":["561f2078cfc3610d0056717d","5697a9ab2cf4060d004ea9e0","56a5f5cafe3e780d00c5068e","56b3584940438c190000475a","56cc77bcfcf2d0130084753d","56cdc2d6388ec62500cfbefc","572142991bbb8a0e0000e0b6","572f931d87e88d0e006c58f6","57fbce1f12ba43290027bc10"],"next":{"pages":[],"description":""},"createdAt":"2015-09-24T17:49:02.564Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"## Getting Started\n\nFollow the [Installation](doc:installation) instructions.\n\nNote, The official Meteor guide also has some instructions on using Chimp for acceptance testing that [you can find by clicking here](http://guide.meteor.com/testing.html#acceptance-testing).\n\nEnsure that your features and tests are in a tests folder; you will encounter a `ReferenceError: module is not defined` error once you start to create your step definitions if they are not.\n\nStart your Meteor application then start Chimp:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"# Cucumber mode\\ncd tests\\nchimp --ddp=http://localhost:3000 --watch --path=tests\\n\\n# Mocha mode\\nchimp --ddp=http://localhost:3000 --watch --mocha --path=tests\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nChimp will now watch the `tests` directory and rerun if any of those change, or if the Meteor app restarts, so you can enjoy a lightning-fast reactive testing experience.\n\nChimp uses Google Chrome by default so you need to install it. If you don't wish to use Chrome, you can specify the `--browser=firefox` flag. You can also choose `phantomjs` and `safari`.\n\n# Meteor Specific Features\n\n## Hot-code reload watch mode\nWhen Meteor is detected in the `--watch` mode, Chimp will connect to your app via DDP and watch for client/server updates. As soon as any are detected, Chimp will rerun the tests/specs that have the watched tags.\n\n## Call a DDP Method\nwhen the `--ddp` flag is passed, you get a global `server` object available in your tests/steps that allows you to call methods via DDP using this syntax:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// using call\\nvar result = server.call('fixtures/resetMyApp');\\n\\n// or apply\\nvar result = server.apply('myMethodWithArgs', [argsArray]);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nNote: for Mocha `server` is defined with in the `it`,`before`,  `beforeEach`, `after` and  `afterEach` callbacks.  `server` is undefined in the `describe` callback.\n\nThese work just like they do on the Meteor server and they are synchronous.\n\nYou can define fixtures using [this method](http://guide.meteor.com/testing.html#creating-integration-test-data) and run `meteor` alongside Chimp using [this method](http://guide.meteor.com/testing.html#creating-acceptance-test-data).\n\n## Execute Code in the Meteor Context\nYou can run code inside the Meteor context from your specs like this:\n\n##### In the Server Context\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var getMeteorSettings = function (setting) {\\n  return Meteor.settings[setting]\\n};\\nvar mySetting = server.execute(getMeteorSettings, 'mySetting');\\nconsole.log(mySetting);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThe call is synchronous, can return complex objects and works both in Cucumber and Mocha.\n\n## Meteor Utility Packages\nIn order for ```server.execute()``` to work, you need to install the[ xolvio:backdoor](https://atmospherejs.com/xolvio/backdoor) package.  We also recommend installing the [xolvio:cleaner](https://atmospherejs.com/xolvio/cleaner) package, which allows for resetting your Mongo test database.\n\n##### In the Client Context\nyou can do this synchronously using WebdriverIO's [execute](http://webdriver.io/api/protocol/execute.html) \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var getUserProfileProperty = function (property) {\\n  return Meteor.user().profile[property];\\n};\\nclient.url('http://localhost:3000'); // the client must be on a Meteor app page\\nvar userName = client.execute(getUserProfileProperty, 'name').value;\\nconsole.log(userName);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n## Try out the example\nSee our [Automated Testing Best Practices](https://github.com/xolvio/automated-testing-best-practices) for examples of using Chimp. \n\nYou may also be interested in the [tests/cucumber](https://github.com/xolvio/Letterpress/tree/master/app/tests/cucumber) directory of our dated - but still useful - Letterpress project.\n\n## Learn Mocha, Cucumber & Chimp\nUse the links on the right hand side to learn more about Chimp, Mocha, Cucumber and other libraries used in this package.\n\n\n---\n\n<a href=\"http://quality.xolv.io/?utm_source=XolvOSS&utm_medium=OSSDocs&utm_content=ChimpRM-Footer&utm_campaign=QFLaunch\"><img src=\"https://files.readme.io/764e495-qualityfasterbook-commas.small.png\" width=\"200\" align=\"right\" /></a>\n##Learn the Fundamentals of Testing, Specifications and Become a Chimp Ninja!\n[Checkout our new book](http://quality.xolv.io/?utm_source=XolvOSS&utm_medium=OSSDocs&utm_content=ChimpRM-Footer&utm_campaign=QFLaunch) where you can learn how to can use Chimp across the Full Stack from React to Node.JS, Mocha, Meteor and more.\n\n\n**[Quality, Faster.](http://quality.xolv.io/?utm_source=XolvOSS&utm_medium=OSSDocs&utm_content=ChimpRM-Footer&utm_campaign=QFLaunch)** By Sam Hatoum, creator of Chimp.\n\nYour support helps us continue our work on Chimp.","excerpt":"Learn the ways of reactive BDD","slug":"getting-started-with-meteor-cucumber","type":"basic","title":"Using Chimp with Meteor"}

Using Chimp with Meteor

Learn the ways of reactive BDD

## Getting Started Follow the [Installation](doc:installation) instructions. Note, The official Meteor guide also has some instructions on using Chimp for acceptance testing that [you can find by clicking here](http://guide.meteor.com/testing.html#acceptance-testing). Ensure that your features and tests are in a tests folder; you will encounter a `ReferenceError: module is not defined` error once you start to create your step definitions if they are not. Start your Meteor application then start Chimp: [block:code] { "codes": [ { "code": "# Cucumber mode\ncd tests\nchimp --ddp=http://localhost:3000 --watch --path=tests\n\n# Mocha mode\nchimp --ddp=http://localhost:3000 --watch --mocha --path=tests", "language": "shell" } ] } [/block] Chimp will now watch the `tests` directory and rerun if any of those change, or if the Meteor app restarts, so you can enjoy a lightning-fast reactive testing experience. Chimp uses Google Chrome by default so you need to install it. If you don't wish to use Chrome, you can specify the `--browser=firefox` flag. You can also choose `phantomjs` and `safari`. # Meteor Specific Features ## Hot-code reload watch mode When Meteor is detected in the `--watch` mode, Chimp will connect to your app via DDP and watch for client/server updates. As soon as any are detected, Chimp will rerun the tests/specs that have the watched tags. ## Call a DDP Method when the `--ddp` flag is passed, you get a global `server` object available in your tests/steps that allows you to call methods via DDP using this syntax: [block:code] { "codes": [ { "code": "// using call\nvar result = server.call('fixtures/resetMyApp');\n\n// or apply\nvar result = server.apply('myMethodWithArgs', [argsArray]);", "language": "javascript" } ] } [/block] Note: for Mocha `server` is defined with in the `it`,`before`, `beforeEach`, `after` and `afterEach` callbacks. `server` is undefined in the `describe` callback. These work just like they do on the Meteor server and they are synchronous. You can define fixtures using [this method](http://guide.meteor.com/testing.html#creating-integration-test-data) and run `meteor` alongside Chimp using [this method](http://guide.meteor.com/testing.html#creating-acceptance-test-data). ## Execute Code in the Meteor Context You can run code inside the Meteor context from your specs like this: ##### In the Server Context [block:code] { "codes": [ { "code": "var getMeteorSettings = function (setting) {\n return Meteor.settings[setting]\n};\nvar mySetting = server.execute(getMeteorSettings, 'mySetting');\nconsole.log(mySetting);", "language": "javascript" } ] } [/block] The call is synchronous, can return complex objects and works both in Cucumber and Mocha. ## Meteor Utility Packages In order for ```server.execute()``` to work, you need to install the[ xolvio:backdoor](https://atmospherejs.com/xolvio/backdoor) package. We also recommend installing the [xolvio:cleaner](https://atmospherejs.com/xolvio/cleaner) package, which allows for resetting your Mongo test database. ##### In the Client Context you can do this synchronously using WebdriverIO's [execute](http://webdriver.io/api/protocol/execute.html) [block:code] { "codes": [ { "code": "var getUserProfileProperty = function (property) {\n return Meteor.user().profile[property];\n};\nclient.url('http://localhost:3000'); // the client must be on a Meteor app page\nvar userName = client.execute(getUserProfileProperty, 'name').value;\nconsole.log(userName);", "language": "javascript" } ] } [/block] ## Try out the example See our [Automated Testing Best Practices](https://github.com/xolvio/automated-testing-best-practices) for examples of using Chimp. You may also be interested in the [tests/cucumber](https://github.com/xolvio/Letterpress/tree/master/app/tests/cucumber) directory of our dated - but still useful - Letterpress project. ## Learn Mocha, Cucumber & Chimp Use the links on the right hand side to learn more about Chimp, Mocha, Cucumber and other libraries used in this package. --- <a href="http://quality.xolv.io/?utm_source=XolvOSS&utm_medium=OSSDocs&utm_content=ChimpRM-Footer&utm_campaign=QFLaunch"><img src="https://files.readme.io/764e495-qualityfasterbook-commas.small.png" width="200" align="right" /></a> ##Learn the Fundamentals of Testing, Specifications and Become a Chimp Ninja! [Checkout our new book](http://quality.xolv.io/?utm_source=XolvOSS&utm_medium=OSSDocs&utm_content=ChimpRM-Footer&utm_campaign=QFLaunch) where you can learn how to can use Chimp across the Full Stack from React to Node.JS, Mocha, Meteor and more. **[Quality, Faster.](http://quality.xolv.io/?utm_source=XolvOSS&utm_medium=OSSDocs&utm_content=ChimpRM-Footer&utm_campaign=QFLaunch)** By Sam Hatoum, creator of Chimp. Your support helps us continue our work on Chimp.