{"__v":11,"_id":"55baf505d0736b3100bf1033","category":{"__v":12,"_id":"559b65be8b04e90d00702d58","pages":["559b65bf8b04e90d00702d5a","55a46241ffd44e0d00fca056","55a46f45e75ca60d00a39323","55a470b768c7e20d0036d4d6","55a4a758dad9d00d0071fcba","55b6b6276127b12500364560","55baf505d0736b3100bf1033","55c25ef1f2cff20d006d0b8a","56269a8b44c87f0d00fe6378","56498f62f176080d000c78ac","566f59c4fc3abb0d0020fcd5","567cd2228eb5b20d0021059d"],"project":"559b65bd8b04e90d00702d54","version":"559b65bd8b04e90d00702d57","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-07-07T05:38:06.409Z","from_sync":false,"order":0,"slug":"chimpjs","title":"Chimp.js"},"parentDoc":null,"project":"559b65bd8b04e90d00702d54","user":"55a4738a68c7e20d0036d4de","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":[],"next":{"pages":[],"description":""},"createdAt":"2015-07-31T04:09:41.674Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":8,"body":"If you have any trouble with the migration, let us know via [GitHub issue](https://github.com/xolvio/chimp/issues) or [Gitter chat](https://gitter.im/xolvio/chimp).\n\n# 1. Start Chimp with \"--sync=false\"\n\nStart chimp with `chimp --sync=false --watch` (add your other options).\n\nThis is you step definition before the migration:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"this.When(/^I visit \\\"([^\\\"]*)\\\"$/, function (url) {\\n  return client.url(url);\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"Promise style\"\n    },\n    {\n      \"code\": \"this.When(/^I visit \\\"([^\\\"]*)\\\"$/, function (url, callback) {\\n  browser.url(url).call(callback);\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"Callback style\"\n    }\n  ]\n}\n[/block]\n# 2. Migrate all step definitions to synchronous style one by one\n\nUse the WebDriver.io commands with the Sync postfix until you have migrated all step definitions to the synchronous style. This way you continuously get feedback from Cucumber if you make any migration errors.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"this.When(/^I visit \\\"([^\\\"]*)\\\"$/, function (url) {\\n  client.urlSync(url);\\n});\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\nWe removed the callback parameter, no longer return anything and use `urlSync`.\n\n# 3. Remove all Sync postfixes\n\nAfter you have migrated all step definitions to the synchronous style, you can remove all Sync postfixes.\n\nUse search and replace with a regular expression. Search for `(?:this\\.)?((?:browser|client|driver|server|ddp)\\.\\w+)Sync` and replace it with `$1`. It removes also the `this.` prefix.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"this.When(/^I visit \\\"([^\\\"]*)\\\"$/, function (url) {\\n  client.url(url);\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n# 4. Start Chimp without \"--sync=false\"\n\nFinally, start Chimp without `--sync=false` (the default is true).","excerpt":"Learn how to convert your asynchronous tests to the synchronous style","slug":"migrate-to-synchronous-style","type":"basic","title":"Migrate to synchronous style"}

Migrate to synchronous style

Learn how to convert your asynchronous tests to the synchronous style

If you have any trouble with the migration, let us know via [GitHub issue](https://github.com/xolvio/chimp/issues) or [Gitter chat](https://gitter.im/xolvio/chimp). # 1. Start Chimp with "--sync=false" Start chimp with `chimp --sync=false --watch` (add your other options). This is you step definition before the migration: [block:code] { "codes": [ { "code": "this.When(/^I visit \"([^\"]*)\"$/, function (url) {\n return client.url(url);\n});", "language": "javascript", "name": "Promise style" }, { "code": "this.When(/^I visit \"([^\"]*)\"$/, function (url, callback) {\n browser.url(url).call(callback);\n});", "language": "javascript", "name": "Callback style" } ] } [/block] # 2. Migrate all step definitions to synchronous style one by one Use the WebDriver.io commands with the Sync postfix until you have migrated all step definitions to the synchronous style. This way you continuously get feedback from Cucumber if you make any migration errors. [block:code] { "codes": [ { "code": "this.When(/^I visit \"([^\"]*)\"$/, function (url) {\n client.urlSync(url);\n});", "language": "javascript", "name": null } ] } [/block] We removed the callback parameter, no longer return anything and use `urlSync`. # 3. Remove all Sync postfixes After you have migrated all step definitions to the synchronous style, you can remove all Sync postfixes. Use search and replace with a regular expression. Search for `(?:this\.)?((?:browser|client|driver|server|ddp)\.\w+)Sync` and replace it with `$1`. It removes also the `this.` prefix. [block:code] { "codes": [ { "code": "this.When(/^I visit \"([^\"]*)\"$/, function (url) {\n client.url(url);\n});", "language": "javascript" } ] } [/block] # 4. Start Chimp without "--sync=false" Finally, start Chimp without `--sync=false` (the default is true).