Repository: Codeception/CodeceptJS (js)

Issue:
clearCookie() hangs forever with no arguments
#### What are you trying to achieve?

Clear all cookies from nightmareJS using `I.clearCookie()`.

#### What do you get instead?

Hangs for an eternity. If I replace `I.clearCookie()` with `I.clearCookie('one-cookie-name')` it will successfully finish almost instantly.

```bash
Basic user-flow --
   [1] Starting recording promises
   Emitted | suite.before
 > Nightmare._beforeSuite
   [1] Queued | hook Nightmare._beforeSuite()
 Test I can log in and do things
   [2] Starting recording promises
   Emitted | test.before
 > Nightmare._before
   [2] Queued | hook Nightmare._before()
   Emitted | test.start ([object Object])
   [2] Queued | clearCookie:
   [2] Queued | amOnPage: https://testsite.com/login
   [2] Queued | fillField: input[type="email"], test@test.com
   [2] Queued | fillField: input[type="password"], testpassword
   [2] Queued | click: [type="submit"]
   [2] Queued | wait: 3
   [2] Queued | see: Some description
   [2] Queued | see: Test, nav .title
   [2] Queued | finish test
   Emitted | step.before (I clear cookie )
 • I clear cookie
   Emitted | step.after (I clear cookie )
```

### Details

* CodeceptJS version: 0.4.9
* NodeJS version: 7.1.0
* Operating System: Mac OS 10.12.1
* NightmareJS version: 2.8.1
* Configuration file:

```js
{
  "tests": "./*_test.js",
  "timeout": 10000,
  "output": "./output",
  "helpers": {
    "Nightmare": {
      "url": "http://localhost",
      "show": true
    }
  },
  "include": {},
  "bootstrap": false,
  "mocha": {},
  "name": "integration-tests"
}
```


Pull request:
[Nightmare] clearCookie should clear all cookies
Fixes #306 

Patch:
diff --git a/lib/actor.js b/lib/actor.js
index e963f852..03eb8ce7 100644
--- a/lib/actor.js
+++ b/lib/actor.js
@@ -4,6 +4,7 @@ let container = require('./container');
 let methodsOfObject = require('./utils').methodsOfObject;
 let recorder = require('./recorder');
 let event = require('./event');
+let output = require('./output');
 
 /**
  * Fetches all methods from all enabled helpers,
@@ -14,10 +15,10 @@ module.exports = function (obj) {
   obj = obj || {};
 
   let helpers = container.helpers();
+
+  // add methods from enabled helpers
   Object.keys(helpers)
-    .map(function (key) {
-      return helpers[key];
-    })
+    .map((key) => helpers[key])
     .forEach((helper) => {
       methodsOfObject(helper, 'Helper')
       .filter((method) => {
@@ -32,11 +33,15 @@ module.exports = function (obj) {
             step.name = actionAlias;
             step.actor = container.translation().I;
           }
+          // add methods to promise chain
           return recordStep(step, Array.prototype.slice.call(arguments));
         };
       });
     });
 
+  // add print comment method
+  obj.say = (msg) => recorder.add(`say ${msg}`, () => output.say(msg));
+
   return obj;
 };
 
diff --git a/lib/helper/Nightmare.js b/lib/helper/Nightmare.js
index 454bdcc3..a1a63899 100644
--- a/lib/helper/Nightmare.js
+++ b/lib/helper/Nightmare.js
@@ -735,6 +735,9 @@ class Nightmare extends Helper {
    * {{> ../webapi/clearCookie}}
    */
   clearCookie(cookie) {
+    if (!cookie) {
+      return this.browser.cookies.clearAll();
+    }
     return this.browser.cookies.clear(cookie);
   }
 


Test patch:
diff --git a/examples/github_test.js b/examples/github_test.js
index 209437cd..060ca3bf 100644
--- a/examples/github_test.js
+++ b/examples/github_test.js
@@ -14,6 +14,7 @@ Scenario('search', (I) => {
 
 Scenario('signin', (I) => {
   I.click('Sign in');
+  I.say('it should not enter');
   I.see('Sign in to GitHub');
   I.fillField('Username or email address', 'something@totest.com');
   I.fillField('Password', '123456');
diff --git a/test/helper/webapi.js b/test/helper/webapi.js
index d681d81d..2fb31039 100644
--- a/test/helper/webapi.js
+++ b/test/helper/webapi.js
@@ -479,6 +479,13 @@ module.exports.tests = function() {
         .then(() => I.clearCookie('auth'))
         .then(() => I.dontSeeCookie('auth'));
     });
+
+    it('should clear all cookies', () => {
+      return I.amOnPage('/')
+        .then(() => I.setCookie({name: 'auth', value: '123456'}))
+        .then(() => I.clearCookie())
+        .then(() => I.dontSeeCookie('auth'));
+    });
   });
 
   describe('#waitForText', () => {
diff --git a/test/unit/actor_test.js b/test/unit/actor_test.js
index d21bdf84..0b233847 100644
--- a/test/unit/actor_test.js
+++ b/test/unit/actor_test.js
@@ -23,8 +23,8 @@ describe('Actor', () => {
     I = actor();
   });
 
-  it('should take all methods of helpers', () => {
-    I.should.have.keys(['hello', 'bye', 'greeting']);
+  it('should take all methods from helpers and built in', () => {
+    I.should.have.keys(['hello', 'bye', 'greeting', 'say']);
   });
 
   it('should return promise', () => {