Methods

Table of Contents

as

Parameters

  • callback function Function to be called with the current object as the parameter

Examples

page.users(1).as(user => {
  assert.equal(user.name, 'John');
  assert.equal(user.lastName, 'Doe');
  assert.equal(user.email, 'john@doe');
});

page.users(2).as(user => {
  assert.equal(user.name, 'John');
  assert.equal(user.lastName, 'Doe');
  assert.equal(user.email, 'john@doe');
});

page.users(3).as(user => {
  assert.equal(user.name, 'John');
  assert.equal(user.lastName, 'Doe');
  assert.equal(user.email, 'john@doe');
});
// Lorem <span>ipsum <strong>dolor</strong></span>

let page = create({
  scope: 'span',
  foo: {
    bar: {
      scope: 'strong'
    }
  }
});

page.foo.bar.as(element => {
  assert.equal(element.text, 'dolor');
});

Returns object this