Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
244
node_modules/jasminewd2/CHANGELOG.md
generated
vendored
Normal file
244
node_modules/jasminewd2/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,244 @@
|
|||
# Changelog for jasminewd2
|
||||
|
||||
# 2.2.0
|
||||
|
||||
## Dependencies
|
||||
Update selenium-webdriverjs to 3.5.0.
|
||||
|
||||
# 2.1.0
|
||||
|
||||
## Features
|
||||
|
||||
- ([41577a5](https://github.com/angular/jasminewd/commit/41577a5e10420d255fb2ec12aa0ea3a8e72f14ca))
|
||||
support native async functions (node 7.6+) (#87)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- ([0137d3f](https://github.com/angular/jasminewd/commit/0137d3f2ae96ef6d51d00055d64b5a8103ae83d0))
|
||||
minor fix to keep stack from original error (#86)
|
||||
|
||||
- ([374f494](https://github.com/angular/jasminewd/commit/374f4946972673f86e06a011e20fc039bb73e234))
|
||||
Allow to specify a function as a custom matcher's message. (#29)
|
||||
|
||||
|
||||
|
||||
# 2.0.0
|
||||
|
||||
(Skipping 1.x because `0.0.1` was originally accidently published as `1.0.0`.)
|
||||
|
||||
## Breaking changes
|
||||
|
||||
- ([fae803c](https://github.com/angular/protractor/commit/fae803cd294e5413523d37bdaa282a9f96cd65a1))
|
||||
pass webdriver instance into `init()` instead of using `require()` (#83)
|
||||
|
||||
So where as before you would write:
|
||||
|
||||
```js
|
||||
require('jasminewd').init(webdriver.promise.controlFlow());
|
||||
```
|
||||
Now you will write:
|
||||
|
||||
```js
|
||||
require('jasminewd').init(webdriver.promise.controlFlow(), webdriver);
|
||||
```
|
||||
|
||||
This removes the dependency on `selenium-webdriver` and protects jasminewd from having a
|
||||
different webdriver instance than Protractor, which could be a huge problem if they had different
|
||||
control flow settings.
|
||||
|
||||
This is a breaking change because it changes the API for the `init` function.
|
||||
|
||||
I also removed the dependency on jasmine, which didn't do anything anyway. Maybe it should have
|
||||
been a peerDependency but those are deprecated.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- ([171cbde](https://github.com/angular/protractor/commit/171cbde22f307bd3cc35c4c1785f171392dca8da))
|
||||
Added types (though you'll have to wait for `@types/jasminewd2` to use them) (#79)
|
||||
|
||||
|
||||
- ([27b4850](https://github.com/angular/protractor/commit/27b485019589cd662ee69e7920893ffa50774b97))
|
||||
Support `SELENIUM_PROMISE_MANAGER=0` (#72)
|
||||
|
||||
There are three major ways this was done in this change:
|
||||
* In `callWhenIdle`, if `flow.isIdle` is not defined, we assume we are working with a
|
||||
`SimpleScheduler` instance, and so the flow is effectively idle.
|
||||
* In `initJasmineWd`, if `flow.reset` is not defined, we assume we are working with a
|
||||
`SimpleScheduler` instance, and so don't bother resetting the flow.
|
||||
* In `wrapInControlFlow`, we use `flow.promise` to create a new promise if possible. Since
|
||||
`new webdriver.promise.Promise()` would have always made a `ManagedPromise`, but `flow.promise`
|
||||
will do the right thing.
|
||||
* In `wrapCompare`, we avoid the webdriver library entirely, and never instance any extra
|
||||
promises. Using `webdriver.promise.when` and `webdriver.promise.all` could have been a problem
|
||||
if our instance of `webdriver` had the control flow turned on, but another instance somewhere
|
||||
did not (or even the same instance, but just at a different point in time). Instead we use the
|
||||
new `maybePromise` tool, which is a mess but is also exactly what we want.
|
||||
* In `specs/*`, we replace `webdriver.promise.fulfilled` with `webdriver.promise.when`.
|
||||
* In `specs/*`, a new version of `adapterSpec.js` and `errorSpec.js` are created:
|
||||
`asyncAwaitAdapterSpec.ts` and `asyncAwaitErrorSpec.ts`.
|
||||
|
||||
I also also fixed a minor bug where we weren't correctly checking for promises inside an array of
|
||||
expected results. Before we had:
|
||||
|
||||
```js
|
||||
expected = Array.prototype.slice.call(arguments, 0);
|
||||
|
||||
...
|
||||
|
||||
webdriver.promise.isPromise(expected);
|
||||
```
|
||||
|
||||
I thought about it for a little while, and there's no way that's correct. `expected` is an
|
||||
`Array<any>`, there's no way it has a `.then` function.
|
||||
|
||||
Closes https://github.com/angular/jasminewd/issues/69
|
||||
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- ([369a249](https://github.com/angular/protractor/commit/369a2499189fbcdc541f354cfede49dba9335e6b))
|
||||
Don't rely on `webdriver.promise` functions (#82)
|
||||
|
||||
While we support `SELENIUM_PROMISE_MANAGER=0` already, we rely on `SimpleScheduler` and some other
|
||||
utility functions which will be going away after the control flow has been fully deprecated. This
|
||||
commit allows jasminewd to work without those utility functions, and even allows people to pass
|
||||
jasminewd their own custom scheduler implementation.
|
||||
|
||||
This does not fix our tests, which will also break when those utility functions go away. See
|
||||
https://github.com/angular/jasminewd/issues/81
|
||||
|
||||
Closes https://github.com/angular/jasminewd/issues/80
|
||||
|
||||
# 0.1.1
|
||||
|
||||
- ([cf1cd34](https://github.com/angular/jasminewd/commit/cf1cd34a4089b6492160349a10d717c7bcaa2c31))
|
||||
chore(isPromise): revert expose deferred object's promise (#78)
|
||||
|
||||
# 0.1.0
|
||||
|
||||
Release for the selenium-webdriver 3.0.1 upgrade.
|
||||
|
||||
# 0.1.0-beta.1
|
||||
|
||||
- ([5fe36a6](https://github.com/angular/jasminewd/commit/5fe36a60102b9033180d68b238ab233a25a52393))
|
||||
deps(selenium-webdriver): upgrade to 3.0.0 (#63)
|
||||
|
||||
fix test "should wait till the expect to run the flow"
|
||||
|
||||
- `isPending` exists but it is no longer part of `ManagedPromise`
|
||||
- `isPending` also is no longer exported in `lib/promise.js`
|
||||
- wrote an `isPending` similar to selenium-webdriver in common.js
|
||||
require a minimum node version
|
||||
|
||||
- selenium-webdriver 3.0.0 requires node >= 6.9.0
|
||||
- update travis test to use node 6
|
||||
|
||||
# 0.1.0-beta.0
|
||||
|
||||
This beta release is for the selenium-webdriver 3.0.0-beta-3 upgrade.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- ([70c9f62](https://github.com/angular/jasminewd/commit/70c9f62af50018bea6ad326e12bacd9ca03e6ae5))
|
||||
upgrade(isPromise): expose the deferred object's promise (#58)
|
||||
|
||||
- isPromise checks to see if the input parameter has a then method
|
||||
- Deferred class has a promise property and no longer has a then method
|
||||
- ([8870365](https://github.com/angular/jasminewd/commit/88703656b4f8a012a084ba184a4fe473f423a200))
|
||||
deps(selenium-webdriver): upgrade to 3.0.0-beta-3 (#57)
|
||||
|
||||
# 0.0.10
|
||||
|
||||
- ([ff2e624](https://github.com/angular/jasminewd/commit/ff2e624159344cd83b04c6a6648334ba12e78ea6))
|
||||
fix(webdriver): Pass in the control flow.
|
||||
|
||||
BREAKING CHANGE: The control flow now needs to be passed in when using jasminewd. This fixes
|
||||
an issue where having multiple versions of selenium-webdriver in a package's dependency tree would
|
||||
result in jasminewd and protractor using different control flows. You now have to initialize
|
||||
jasminewd before you can use it, like so: `require('jasminewd2').init(webdriver.promise.controlFlow());`
|
||||
|
||||
See https://github.com/angular/protractor/issues/3505
|
||||
|
||||
- ([db26b1a](https://github.com/angular/jasminewd/commit/db26b1a1e66477a6f526dac56ecaaa50d2cf4700))
|
||||
fix(stacktrace): do not crash if beforeEach block is rejected without any stated reason (#45)
|
||||
|
||||
# 0.0.9
|
||||
|
||||
- ([790c81e](https://github.com/angular/protractor/commit/790c81eb0aba880fffbdcb4e834eb2161141620c))
|
||||
fix(expectations): allow custom matchers to return a promise when actual is not a promise
|
||||
|
||||
See angular/protractor#2964
|
||||
|
||||
|
||||
# 0.0.8
|
||||
|
||||
- ([5abc745](https://github.com/angular/protractor/commit/5abc7457cd73a4a4ba70b3c9ceeadac6d42bbd76))
|
||||
chore(jasmine): update MatchFactory to allow message as function
|
||||
|
||||
- ([750898c](https://github.com/angular/protractor/commit/750898c90a1cc1bef09384b60ef6e15adfe734f7))
|
||||
fix(expectation): expectations without promises no longer add to task queue
|
||||
|
||||
Instead, expectations without promises in either expected or actual are unchanged from the
|
||||
original Jasmine implementation.
|
||||
|
||||
See https://github.com/angular/protractor/issues/2894
|
||||
|
||||
# 0.0.7
|
||||
|
||||
- ([55fd11e](https://github.com/angular/protractor/commit/55fd11e69c2f1ba8fba9a19a8acccbe933896084))
|
||||
fix(index): forward it's return value
|
||||
|
||||
- ([f4c30a0](https://github.com/angular/protractor/commit/f4c30a0023c6ec33b15df762226c3fe8e741d26e))
|
||||
fix: allow empty it functions
|
||||
|
||||
# 0.0.6
|
||||
|
||||
- ([4776c16](https://github.com/angular/jasminewd/commit/4776c16b9a9f3a9a3de8a8dddc0e051cb32331b4))
|
||||
chore(selenium-webdriver): update selenium webdriver to 2.47.0
|
||||
|
||||
Update selenium-webdriver to 2.47.0 from 2.45.1. This update introduces a convoluted situation
|
||||
where some tests in Proractor's suite would hang - see
|
||||
https://github.com/angular/protractor/issues/2245
|
||||
|
||||
This change includes a fix for those issues which removes the explicit
|
||||
`flow.execute` wrapper around `expect` calls. This appears not to introduce any issues to existing
|
||||
tests.
|
||||
|
||||
# 0.0.5
|
||||
|
||||
- ([037c7de](https://github.com/angular/jasminewd/commit/037c7de7fea4de068734b6fa250d145800863633))
|
||||
chore(dependencies): update Jasmine to 2.3.1
|
||||
|
||||
# 0.0.4
|
||||
|
||||
- ([8f8b8b3](https://github.com/angular/jasminewd/commit/8f8b8b39e779559fd3b29b138d7577658b8a64b7))
|
||||
tests(context): test that the `this` variable points to the right thing
|
||||
|
||||
Note: this means that using `this.addMatchers` no longer works inside before blocks or specs. It
|
||||
should have been changed to `jamsine.addMatchers` since the upgrade to Jasmine 2. It was still
|
||||
working by accident up until the previous commit.
|
||||
|
||||
- ([c0f13d2](https://github.com/angular/jasminewd/commit/c0f13d254966c859db22d020a5390138dbf48e64))
|
||||
refactor(asyncTestFn): refactor async test wrapping to show more info
|
||||
|
||||
Test wrapping for Jasmine 2 now more closely follows the test wrapping for Mocha at
|
||||
https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/testing/index.js
|
||||
|
||||
This also adds more information to the task names in the control flow, for easier debugging.
|
||||
|
||||
# 0.0.3
|
||||
|
||||
- ([161e1fa](https://github.com/angular/jasminewd/commit/161e1fa48deaa5ea0f485027ea8ae41562864936))
|
||||
fix(errors): update webdriverjs, fix asynchronous error output
|
||||
|
||||
Add some console logging, remove useless info about the last running task in the control flow, and
|
||||
fix error where problems reported from done.fail were getting pushed into the following spec.
|
||||
|
||||
Closes #18
|
||||
|
||||
- ([fdb03a3](https://github.com/angular/jasminewd/commit/fdb03a388d4846952c09fb0ad75a37b46674c750))
|
||||
docs(readme): add note about jasmine 1 vs jasmine 2
|
||||
|
||||
- ([acaec8b](https://github.com/angular/jasminewd/commit/acaec8bdd157e9933d608c66204a52335fb46ee4))
|
||||
feat(index): add jasmine2.0 support
|
21
node_modules/jasminewd2/LICENSE
generated
vendored
Normal file
21
node_modules/jasminewd2/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017 Google, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
94
node_modules/jasminewd2/README.md
generated
vendored
Normal file
94
node_modules/jasminewd2/README.md
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
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.
|
354
node_modules/jasminewd2/index.js
generated
vendored
Normal file
354
node_modules/jasminewd2/index.js
generated
vendored
Normal file
|
@ -0,0 +1,354 @@
|
|||
/**
|
||||
* Adapts Jasmine-Node tests to work better with WebDriverJS. Borrows
|
||||
* heavily from the mocha WebDriverJS adapter at
|
||||
* https://code.google.com/p/selenium/source/browse/javascript/node/selenium-webdriver/testing/index.js
|
||||
*/
|
||||
|
||||
var WebElement; // Equal to webdriver.WebElement
|
||||
var idleEventName = 'idle'; // Equal to webdriver.promise.ControlFlow.EventType.IDLE
|
||||
var maybePromise = require('./maybePromise');
|
||||
|
||||
/**
|
||||
* Validates that the parameter is a function.
|
||||
* @param {Object} functionToValidate The function to validate.
|
||||
* @throws {Error}
|
||||
* @return {Object} The original parameter.
|
||||
*/
|
||||
function validateFunction(functionToValidate) {
|
||||
if (functionToValidate && typeof functionToValidate === 'function') {
|
||||
return functionToValidate;
|
||||
} else {
|
||||
throw Error(functionToValidate + ' is not a function');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that the parameter is a number.
|
||||
* @param {Object} numberToValidate The number to validate.
|
||||
* @throws {Error}
|
||||
* @return {Object} The original number.
|
||||
*/
|
||||
function validateNumber(numberToValidate) {
|
||||
if (!isNaN(numberToValidate)) {
|
||||
return numberToValidate;
|
||||
} else {
|
||||
throw Error(numberToValidate + ' is not a number');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that the parameter is a string.
|
||||
* @param {Object} stringToValidate The string to validate.
|
||||
* @throws {Error}
|
||||
* @return {Object} The original string.
|
||||
*/
|
||||
function validateString(stringtoValidate) {
|
||||
if (typeof stringtoValidate == 'string' || stringtoValidate instanceof String) {
|
||||
return stringtoValidate;
|
||||
} else {
|
||||
throw Error(stringtoValidate + ' is not a string');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls a function once the scheduler is idle. If the scheduler does not support the idle API,
|
||||
* calls the function immediately. See scheduler.md#idle-api for details.
|
||||
*
|
||||
* @param {Object} scheduler The scheduler to wait for.
|
||||
* @param {!Function} fn The function to call.
|
||||
*/
|
||||
function callWhenIdle(scheduler, fn) {
|
||||
if (!scheduler.once || !scheduler.isIdle || scheduler.isIdle()) {
|
||||
fn();
|
||||
} else {
|
||||
scheduler.once(idleEventName, function() { fn(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wraps a function so it runs inside a scheduler's `execute()` block.
|
||||
*
|
||||
* In the most common case, this means wrapping in a `webdriver.promise.ControlFlow` instance
|
||||
* to wait for the control flow to complete one task before starting the next. See scheduler.md
|
||||
* for details.
|
||||
*
|
||||
* @param {!Object} scheduler See scheduler.md for details.
|
||||
* @param {!Function} newPromise Makes a new promise using whatever implementation the scheduler
|
||||
* prefers.
|
||||
* @param {!Function} globalFn The function to wrap.
|
||||
* @param {!string} fnName The name of the function being wrapped (e.g. `'it'`).
|
||||
* @return {!Function} The new function.
|
||||
*/
|
||||
function wrapInScheduler(scheduler, newPromise, globalFn, fnName) {
|
||||
return function() {
|
||||
var driverError = new Error();
|
||||
driverError.stack = driverError.stack.replace(/ +at.+jasminewd.+\n/, '');
|
||||
|
||||
function asyncTestFn(fn, description) {
|
||||
description = description ? ('("' + description + '")') : '';
|
||||
return function(done) {
|
||||
var async = fn.length > 0;
|
||||
var testFn = fn.bind(this);
|
||||
|
||||
scheduler.execute(function schedulerExecute() {
|
||||
return newPromise(function(fulfill, reject) {
|
||||
function wrappedReject(err) {
|
||||
if(err instanceof Error)
|
||||
reject(err);
|
||||
else
|
||||
reject(new Error(err));
|
||||
}
|
||||
if (async) {
|
||||
// If testFn is async (it expects a done callback), resolve the promise of this
|
||||
// test whenever that callback says to. Any promises returned from testFn are
|
||||
// ignored.
|
||||
var proxyDone = fulfill;
|
||||
proxyDone.fail = wrappedReject;
|
||||
testFn(proxyDone);
|
||||
} else {
|
||||
// Without a callback, testFn can return a promise, or it will
|
||||
// be assumed to have completed synchronously.
|
||||
var ret = testFn();
|
||||
if (maybePromise.isPromise(ret)) {
|
||||
ret.then(fulfill, wrappedReject);
|
||||
} else {
|
||||
fulfill(ret);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 'Run ' + fnName + description + ' in control flow').then(
|
||||
callWhenIdle.bind(null, scheduler, done), function(err) {
|
||||
if (!err) {
|
||||
err = new Error('Unknown Error');
|
||||
err.stack = '';
|
||||
}
|
||||
err.stack = err.stack + '\nFrom asynchronous test: \n' + driverError.stack;
|
||||
callWhenIdle(scheduler, done.fail.bind(done, err));
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
var description, func, timeout;
|
||||
switch (fnName) {
|
||||
case 'it':
|
||||
case 'fit':
|
||||
description = validateString(arguments[0]);
|
||||
if (!arguments[1]) {
|
||||
return globalFn(description);
|
||||
}
|
||||
func = validateFunction(arguments[1]);
|
||||
if (!arguments[2]) {
|
||||
return globalFn(description, asyncTestFn(func, description));
|
||||
} else {
|
||||
timeout = validateNumber(arguments[2]);
|
||||
return globalFn(description, asyncTestFn(func, description), timeout);
|
||||
}
|
||||
break;
|
||||
case 'beforeEach':
|
||||
case 'afterEach':
|
||||
case 'beforeAll':
|
||||
case 'afterAll':
|
||||
func = validateFunction(arguments[0]);
|
||||
if (!arguments[1]) {
|
||||
globalFn(asyncTestFn(func));
|
||||
} else {
|
||||
timeout = validateNumber(arguments[1]);
|
||||
globalFn(asyncTestFn(func), timeout);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Error('invalid function: ' + fnName);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the JasmineWd adapter with a particlar scheduler, generally a webdriver control flow.
|
||||
*
|
||||
* @param {Object=} scheduler The scheduler to wrap tests in. See scheduler.md for details.
|
||||
* Defaults to a mock scheduler that calls functions immediately.
|
||||
* @param {Object=} webdriver The result of `require('selenium-webdriver')`. Passed in here rather
|
||||
* than required by jasminewd directly so that jasminewd can't end up up with a different version
|
||||
* of `selenium-webdriver` than your tests use. If not specified, jasminewd will still work, but
|
||||
* it won't check for `WebElement` instances in expect() statements and could cause control flow
|
||||
* problems if your tests are using an old version of `selenium-webdriver` (e.g. version 2.53.0).
|
||||
*/
|
||||
function initJasmineWd(scheduler, webdriver) {
|
||||
if (jasmine.JasmineWdInitialized) {
|
||||
throw Error('JasmineWd already initialized when init() was called');
|
||||
}
|
||||
jasmine.JasmineWdInitialized = true;
|
||||
|
||||
|
||||
// Pull information from webdriver instance
|
||||
if (webdriver) {
|
||||
WebElement = webdriver.WebElement || WebElement;
|
||||
idleEventName = (
|
||||
webdriver.promise &&
|
||||
webdriver.promise.ControlFlow &&
|
||||
webdriver.promise.ControlFlow.EventType &&
|
||||
webdriver.promise.ControlFlow.EventType.IDLE
|
||||
) || idleEventname;
|
||||
}
|
||||
|
||||
// Default to mock scheduler
|
||||
if (!scheduler) {
|
||||
scheduler = { execute: function(fn) {
|
||||
return Promise.resolve().then(fn);
|
||||
} };
|
||||
}
|
||||
|
||||
// Figure out how we're getting new promises
|
||||
var newPromise;
|
||||
if (typeof scheduler.promise == 'function') {
|
||||
newPromise = scheduler.promise.bind(scheduler);
|
||||
} else if (webdriver && webdriver.promise && webdriver.promise.ControlFlow &&
|
||||
(scheduler instanceof webdriver.promise.ControlFlow) &&
|
||||
(webdriver.promise.USE_PROMISE_MANAGER !== false)) {
|
||||
newPromise = function(resolver) {
|
||||
return new webdriver.promise.Promise(resolver, scheduler);
|
||||
};
|
||||
} else {
|
||||
newPromise = function(resolver) {
|
||||
return new Promise(resolver);
|
||||
};
|
||||
}
|
||||
|
||||
// Wrap functions
|
||||
global.it = wrapInScheduler(scheduler, newPromise, global.it, 'it');
|
||||
global.fit = wrapInScheduler(scheduler, newPromise, global.fit, 'fit');
|
||||
global.beforeEach = wrapInScheduler(scheduler, newPromise, global.beforeEach, 'beforeEach');
|
||||
global.afterEach = wrapInScheduler(scheduler, newPromise, global.afterEach, 'afterEach');
|
||||
global.beforeAll = wrapInScheduler(scheduler, newPromise, global.beforeAll, 'beforeAll');
|
||||
global.afterAll = wrapInScheduler(scheduler, newPromise, global.afterAll, 'afterAll');
|
||||
|
||||
// Reset API
|
||||
if (scheduler.reset) {
|
||||
// On timeout, the flow should be reset. This will prevent webdriver tasks
|
||||
// from overflowing into the next test and causing it to fail or timeout
|
||||
// as well. This is done in the reporter instead of an afterEach block
|
||||
// to ensure that it runs after any afterEach() blocks with webdriver tasks
|
||||
// get to complete first.
|
||||
jasmine.getEnv().addReporter(new OnTimeoutReporter(function() {
|
||||
console.warn('A Jasmine spec timed out. Resetting the WebDriver Control Flow.');
|
||||
scheduler.reset();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
var originalExpect = global.expect;
|
||||
global.expect = function(actual) {
|
||||
if (WebElement && (actual instanceof WebElement)) {
|
||||
throw Error('expect called with WebElement argument, expected a Promise. ' +
|
||||
'Did you mean to use .getText()?');
|
||||
}
|
||||
return originalExpect(actual);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a matcher wrapper that resolves any promises given for actual and
|
||||
* expected values, as well as the `pass` property of the result.
|
||||
*
|
||||
* Wrapped matchers will return either `undefined` or a promise which resolves
|
||||
* when the matcher is complete, depending on if the matcher had to resolve any
|
||||
* promises.
|
||||
*/
|
||||
jasmine.Expectation.prototype.wrapCompare = function(name, matcherFactory) {
|
||||
return function() {
|
||||
var expected = Array.prototype.slice.call(arguments, 0),
|
||||
expectation = this,
|
||||
matchError = new Error("Failed expectation");
|
||||
|
||||
matchError.stack = matchError.stack.replace(/ +at.+jasminewd.+\n/, '');
|
||||
|
||||
// Return either undefined or a promise of undefined
|
||||
return maybePromise(expectation.actual, function(actual) {
|
||||
return maybePromise.all(expected, function(expected) {
|
||||
return compare(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
function compare(actual, expected) {
|
||||
var args = expected.slice(0);
|
||||
args.unshift(actual);
|
||||
|
||||
var matcher = matcherFactory(expectation.util, expectation.customEqualityTesters);
|
||||
var matcherCompare = matcher.compare;
|
||||
|
||||
if (expectation.isNot) {
|
||||
matcherCompare = matcher.negativeCompare || defaultNegativeCompare;
|
||||
}
|
||||
|
||||
var result = matcherCompare.apply(null, args);
|
||||
|
||||
return maybePromise(result.pass, compareDone);
|
||||
|
||||
// compareDone always returns undefined
|
||||
function compareDone(pass) {
|
||||
var message = '';
|
||||
|
||||
if (!pass) {
|
||||
if (!result.message) {
|
||||
args.unshift(expectation.isNot);
|
||||
args.unshift(name);
|
||||
message = expectation.util.buildFailureMessage.apply(null, args);
|
||||
} else {
|
||||
if (Object.prototype.toString.apply(result.message) === '[object Function]') {
|
||||
message = result.message(expectation.isNot);
|
||||
} else {
|
||||
message = result.message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (expected.length == 1) {
|
||||
expected = expected[0];
|
||||
}
|
||||
var res = {
|
||||
matcherName: name,
|
||||
passed: pass,
|
||||
message: message,
|
||||
actual: actual,
|
||||
expected: expected,
|
||||
error: matchError
|
||||
};
|
||||
expectation.addExpectationResult(pass, res);
|
||||
}
|
||||
|
||||
function defaultNegativeCompare() {
|
||||
var result = matcher.compare.apply(null, args);
|
||||
result.pass = maybePromise(result.pass, function(pass) {
|
||||
return !pass;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Re-add core matchers so they are wrapped.
|
||||
jasmine.Expectation.addCoreMatchers(jasmine.matchers);
|
||||
|
||||
/**
|
||||
* A Jasmine reporter which does nothing but execute the input function
|
||||
* on a timeout failure.
|
||||
*/
|
||||
var OnTimeoutReporter = function(fn) {
|
||||
this.callback = fn;
|
||||
};
|
||||
|
||||
OnTimeoutReporter.prototype.specDone = function(result) {
|
||||
if (result.status === 'failed') {
|
||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||
var failureMessage = result.failedExpectations[i].message;
|
||||
|
||||
if (failureMessage.match(/Timeout/)) {
|
||||
this.callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.init = initJasmineWd;
|
44
node_modules/jasminewd2/package.json
generated
vendored
Normal file
44
node_modules/jasminewd2/package.json
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "jasminewd2",
|
||||
"description": "WebDriverJS adapter for Jasmine2.",
|
||||
"homepage": "https://github.com/angular/jasminewd",
|
||||
"keywords": [
|
||||
"test",
|
||||
"testing",
|
||||
"webdriver",
|
||||
"webdriverjs",
|
||||
"selenium",
|
||||
"jasmine"
|
||||
],
|
||||
"author": "Julie Ralph <ju.ralph@gmail.com>",
|
||||
"devDependencies": {
|
||||
"@types/jasmine": "^2.5.40",
|
||||
"@types/node": "^6.0.56",
|
||||
"@types/selenium-webdriver": "^2.53.38",
|
||||
"jasmine": "2.4.1",
|
||||
"jshint": "^2.9.4",
|
||||
"selenium-webdriver": "3.5.0",
|
||||
"tslint": "^4.2.0",
|
||||
"tslint-eslint-rules": "^3.2.3",
|
||||
"typescript": "^2.0.10",
|
||||
"vrsource-tslint-rules": "^4.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/angular/jasminewd.git"
|
||||
},
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"jshint": "jshint index.js spec",
|
||||
"tslint": "tslint spec/*.ts",
|
||||
"lint": "npm run jshint && npm run tslint",
|
||||
"tsc": "tsc; cp spec/*.js built_spec",
|
||||
"pretest": "npm run lint && npm run tsc",
|
||||
"test": "scripts/test.sh"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 6.9.x"
|
||||
},
|
||||
"version": "2.2.0"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue