# jasminewd2

> WebDriverJS adapter for Jasmine2.

Latest version **2.2.0** (published 2017-10-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install jasminewd2
pnpm add jasminewd2
yarn add jasminewd2
bun add jasminewd2
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2017-10-05 |
| First published | 2015-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/jasminewd2) |
| Module format | CommonJS |
| Node | >= 6.9.x |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 46 |
| Author | Julie Ralph |
| Maintainers | hankduan, angularcore, petebd |
| Keywords | test, testing, webdriver, webdriverjs, selenium, jasmine |

## Links

- npm: https://www.npmjs.com/package/jasminewd2
- Repository: https://github.com/angular/jasminewd
- Issues: https://github.com/angular/jasminewd/issues
- npm.io page: https://npm.io/package/jasminewd2

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 2.2.0 (latest) — 2017-10-05
- 0.1.0-beta.1 (beta) — 2016-11-08
- 2.1.0 — 2017-05-09
- 2.0.0 — 2017-01-21
- 0.1.1 — 2017-01-10
- 0.1.0 — 2017-01-06
- 0.1.0-beta.0 — 2016-10-28
- 0.0.10 — 2016-09-07
- 0.0.9 — 2016-04-25
- 0.0.8 — 2016-02-09
- 0.0.7 — 2016-02-08
- 0.0.6 — 2015-09-29
- 0.0.5 — 2015-05-15
- 0.0.4 — 2015-04-14
- 0.0.3 — 2015-03-18
- … 2 more at https://npm.io/package/jasminewd2/versions

## README

jasminewd2 [![Build Status](https://travis-ci.org/angular/jasminewd.svg?branch=jasminewd2)](https://travis-ci.org/angular/jasminewd)
=========

Adapter for Jasmine-to-WebDriverJS. Used by [Protractor](http://www.github.com/angular/protractor).

**Important:** There are two active branches of jasminewd.

 - [jasminewd1](https://github.com/angular/jasminewd/tree/jasminewd1) is an adapter for Jasmine 1.3, and uses the package minijasminenode. It is published to npm as `jasminewd`.
 - [jasminewd2](https://github.com/angular/jasminewd/tree/jasminewd2) is an adapter for Jasmine 2.x, and uses the package jasmine. It is published to npm as `jasminewd2`.

Features
--------

 - Automatically makes tests asynchronously wait until the WebDriverJS control flow is empty.

 - If a `done` function is passed to the test, waits for both the control flow and until done is called.

 - If a test returns a promise, waits for both the control flow and the promise to resolve.

 - Enhances `expect` so that it automatically unwraps promises before performing the assertion.

Installation
------------
```
npm install jasminewd2
```

Usage
-----

In your setup:

```js
var JasmineRunner = require('jasmine');
var jrunner = new JasmineRunner();
var webdriver = require('selenium-webdriver');

global.driver = new webdriver.Builder().
    usingServer('http://localhost:4444/wd/hub').
    withCapabilities({browserName: 'chrome'}).
    build();

require('jasminewd2').init(driver.controlFlow(), webdriver);

jrunner.projectBaseDir = '';
jrunner.execute(['**/*_spec.js']);
```

In your tests:

```js
describe('tests with webdriver', function() {
  it('will wait until webdriver is done', function() {
    // This will be an asynchronous test. It will finish once webdriver has
    // loaded the page, found the element, and gotten its text.
    driver.get('http://www.example.com');

    var myElement = driver.findElement(webdriver.By.id('hello'));

    // Here, expect understands that myElement.getText() is a promise,
    // and resolves it before asserting.
    expect(myElement.getText()).toEqual('hello world');
  });
})
```

TypeScript
----------

For the typings related to the changes in the global jasmine variables (e.g.
allowing `it()` blocks to return a promise), we publish the package
`@types/jasminewd2`.  If you are writing tests using jasminewd (including
Protractor tests), be sure to include `@types/jasminewd2` in your
`devDependencies`, as these global type modifications are ***not*** bundled with
the `jasminewd2` npm module.

jasminewd also exports one function directly: `init`.  Unfortunately, we do not
publish typings for this function.  If you call this function directly (e.g. you
are a Protractor dev), you should simply do:

```ts
require('jasminewd2').init(controlFlow, webdriver);
```

`async` functions / `await`
---------------------------

`async` functions and the `await` keyword are likely coming in ES2017 (ES8), and
available via several compilers.  At the moment, they often break the WebDriver
control flow.
([GitHub issue](https://github.com/SeleniumHQ/selenium/issues/3037)).  You can
still use them, but if you do then you will have to use `await`/Promises for
almost all your synchronization.  See `spec/asyncAwaitAdapterSpec.ts` and
`spec/asyncAwaitErrorSpec.ts` for examples.

---
_Source: https://npm.io/package/jasminewd2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
