Skip to content
This repository was archived by the owner on Dec 16, 2023. It is now read-only.

Either chaining is broken, or documentation is wrong #1188

Closed
Mattsi-Jansky opened this issue Jan 17, 2019 · 3 comments
Closed

Either chaining is broken, or documentation is wrong #1188

Mattsi-Jansky opened this issue Jan 17, 2019 · 3 comments

Comments

@Mattsi-Jansky
Copy link

Mattsi-Jansky commented Jan 17, 2019

In release 6.0.0, 2018-04-02 the following breaking change was made (according to the changelog): "Various browser methods, like focus, fill, etc now take a callback, or return a promise."

According to the documentation, the following syntax should work:

      browser
        .fill('email',    '[email protected]')
        .fill('password', 'eat-the-living')
        .pressButton('Sign Me Up!', done);

It implies that fill will return a copy of browser, enabling chaining. However, since 6.0.0 this isn't the case- fill (and a number of similar methods) returns a promise. If you try to run the basic example above from the Zombie documentation (from both the README, and the website http://zombie.js.org/) it won't work. Either the documentation needs to be updated, or chaining needs to be fixed.

@Mattsi-Jansky
Copy link
Author

Mattsi-Jansky commented Jan 17, 2019

Proof of concept based on the example from README.md:

const Browser = require('zombie');

// We're going to make requests to http://example.com/signup
// Which will be routed to our test server localhost:3000
Browser.localhost('example.com', 3000);

describe('User visits signup page', function() {

  const browser = new Browser();

  before(function(done) {
    browser.visit('http://www.google.com', done);
  });

  describe('submits form', function() {

    before(function(done) {
      browser
        .fill('input',    '[email protected]')
        .fill('input',    '[email protected]')
        .pressButton('Sign Me Up!', done);
    });

    it('should be successful', function() {
      browser.assert.success();
    });

    it('should see welcome page', function() {
      browser.assert.text('title', 'Welcome To Brains Depot');
    });
  });
});

Running this outputs:

  User visits signup page
    submits form
      1) "before all" hook


  0 passing (263ms)
  1 failing

  1) User visits signup page
       submits form
         "before all" hook:
     TypeError: browser.fill(...).fill is not a function
      at Context.<anonymous> (test.js:20:10)

Because a promise does not have a fill function, it fails.

@sami-sweng
Copy link

Yup, same issue.

From the source code If called without callback, returns a promise

@MiloATH
Copy link
Contributor

MiloATH commented Aug 31, 2019

Documentation was wrong and has been fixed. Code in README fixed in #1196.

@assaf assaf closed this as completed Aug 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants