Adapter for Jasmine-\/to-\/\+Web\+Driver\+JS. Used by \href{http://www.github.com/angular/protractor}{\texttt{ Protractor}}.

{\bfseries{Important\+:}} There are two active branches of jasminewd.


\begin{DoxyItemize}
\item \href{https://github.com/angular/jasminewd/tree/jasminewd1}{\texttt{ jasminewd1}} is an adapter for Jasmine 1.\+3, and uses the package minijasminenode. It is published to npm as {\ttfamily jasminewd}.
\item \href{https://github.com/angular/jasminewd/tree/jasminewd2}{\texttt{ jasminewd2}} is an adapter for Jasmine 2.\+x, and uses the package jasmine. It is published to npm as {\ttfamily jasminewd2}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_jasminewd2_README_autotoc_md13941}{}\doxysection{Features}\label{md_sfcode_node_modules_jasminewd2_README_autotoc_md13941}

\begin{DoxyItemize}
\item Automatically makes tests asynchronously wait until the Web\+Driver\+JS control flow is empty.
\item If a {\ttfamily done} function is passed to the test, waits for both the control flow and until done is called.
\item If a test returns a promise, waits for both the control flow and the promise to resolve.
\item Enhances {\ttfamily expect} so that it automatically unwraps promises before performing the assertion.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_jasminewd2_README_autotoc_md13942}{}\doxysection{Installation}\label{md_sfcode_node_modules_jasminewd2_README_autotoc_md13942}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install jasminewd2 }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_jasminewd2_README_autotoc_md13943}{}\doxysection{Usage}\label{md_sfcode_node_modules_jasminewd2_README_autotoc_md13943}
In your setup\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var JasmineRunner = require('jasmine');}
\DoxyCodeLine{var jrunner = new JasmineRunner();}
\DoxyCodeLine{var webdriver = require('selenium-\/webdriver');}
\DoxyCodeLine{}
\DoxyCodeLine{global.driver = new webdriver.Builder().}
\DoxyCodeLine{    usingServer('http://localhost:4444/wd/hub').}
\DoxyCodeLine{    withCapabilities(\{browserName: 'chrome'\}).}
\DoxyCodeLine{    build();}
\DoxyCodeLine{}
\DoxyCodeLine{require('jasminewd2').init(driver.controlFlow(), webdriver);}
\DoxyCodeLine{}
\DoxyCodeLine{jrunner.projectBaseDir = '';}
\DoxyCodeLine{jrunner.execute(['**/*\_spec.js']); }

\end{DoxyCode}


In your tests\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{describe('tests with webdriver', function() \{}
\DoxyCodeLine{  it('will wait until webdriver is done', function() \{}
\DoxyCodeLine{    // This will be an asynchronous test. It will finish once webdriver has}
\DoxyCodeLine{    // loaded the page, found the element, and gotten its text.}
\DoxyCodeLine{    driver.get('http://www.example.com');}
\DoxyCodeLine{}
\DoxyCodeLine{    var myElement = driver.findElement(webdriver.By.id('hello'));}
\DoxyCodeLine{}
\DoxyCodeLine{    // Here, expect understands that myElement.getText() is a promise,}
\DoxyCodeLine{    // and resolves it before asserting.}
\DoxyCodeLine{    expect(myElement.getText()).toEqual('hello world');}
\DoxyCodeLine{  \});}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_jasminewd2_README_autotoc_md13944}{}\doxysection{Type\+Script}\label{md_sfcode_node_modules_jasminewd2_README_autotoc_md13944}
For the typings related to the changes in the global jasmine variables (e.\+g. allowing {\ttfamily it()} blocks to return a promise), we publish the package {\ttfamily @types/jasminewd2}. If you are writing tests using jasminewd (including Protractor tests), be sure to include {\ttfamily @types/jasminewd2} in your {\ttfamily dev\+Dependencies}, as these global type modifications are {\itshape {\bfseries{not}}} bundled with the {\ttfamily jasminewd2} npm module.

jasminewd also exports one function directly\+: {\ttfamily 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\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{require('jasminewd2').init(controlFlow, webdriver); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_jasminewd2_README_autotoc_md13945}{}\doxysection{$<$tt$>$async$<$/tt$>$ functions / $<$tt$>$await$<$/tt$>$}\label{md_sfcode_node_modules_jasminewd2_README_autotoc_md13945}
{\ttfamily async} functions and the {\ttfamily await} keyword are likely coming in ES2017 (ES8), and available via several compilers. At the moment, they often break the Web\+Driver control flow. (\href{https://github.com/SeleniumHQ/selenium/issues/3037}{\texttt{ Git\+Hub issue}}). You can still use them, but if you do then you will have to use {\ttfamily await}/\+Promises for almost all your synchronization. See {\ttfamily spec/async\+Await\+Adapter\+Spec.\+ts} and {\ttfamily spec/async\+Await\+Error\+Spec.\+ts} for examples. 