Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jasminewd2

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasminewd2

WebDriverJS adapter for Jasmine2.

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
792K
decreased by-15.98%
Maintainers
3
Weekly downloads
 
Created

What is jasminewd2?

The jasminewd2 package is a bridge between Jasmine and WebDriverJS, allowing for seamless integration of asynchronous WebDriverJS commands in Jasmine tests. It provides utilities to handle promises and asynchronous operations in a more readable and manageable way.

What are jasminewd2's main functionalities?

Asynchronous Testing

This feature allows you to write tests that wait for promises to resolve before making assertions. The code sample demonstrates how to navigate to a URL and then check the page title, ensuring that the test waits for the navigation to complete.

describe('Asynchronous specs', function() {
  it('should wait for the promise to resolve', function() {
    return browser.get('http://www.example.com').then(function() {
      expect(browser.getTitle()).toEqual('Example Domain');
    });
  });
});

Custom Matchers

This feature allows you to define custom matchers to extend Jasmine's built-in matchers. The code sample shows how to create a custom matcher `toBeWithinRange` that checks if a number falls within a specified range.

describe('Custom matchers', function() {
  beforeEach(function() {
    jasmine.addMatchers({
      toBeWithinRange: function() {
        return {
          compare: function(actual, expected) {
            var result = {};
            result.pass = actual >= expected[0] && actual <= expected[1];
            if (result.pass) {
              result.message = 'Expected ' + actual + ' to be within range ' + expected;
            } else {
              result.message = 'Expected ' + actual + ' to be within range ' + expected + ' but it was not';
            }
            return result;
          }
        };
      }
    });
  });

  it('is within range', function() {
    expect(100).toBeWithinRange([90, 110]);
  });
});

Handling Asynchronous Setup and Teardown

This feature allows you to perform asynchronous operations in setup and teardown functions. The code sample demonstrates how to navigate to a URL before all tests and quit the browser after all tests, ensuring that these operations complete before proceeding.

describe('Asynchronous setup and teardown', function() {
  beforeAll(function(done) {
    browser.get('http://www.example.com').then(function() {
      done();
    });
  });

  afterAll(function(done) {
    browser.quit().then(function() {
      done();
    });
  });

  it('should have a title', function() {
    expect(browser.getTitle()).toEqual('Example Domain');
  });
});

Other packages similar to jasminewd2

Keywords

FAQs

Package last updated on 09 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc