New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

browser-monkey

Package Overview
Dependencies
Maintainers
2
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-monkey - npm Package Compare versions

Comparing version 1.17.1 to 1.18.0

21

index.js

@@ -383,4 +383,4 @@ var retry = require('trytryagain');

var elements = findWithFinder($(selector()), 0);
if (!allowMultiple && elements.length !== 1) {
throw new Error("expected to find exactly one element: " + self.printFinders(self.finders) + ', but found :' + elementsToString(elements));
if (!allowMultiple) {
expectOneElement(self, elements);
}

@@ -390,2 +390,7 @@ return elements.toArray();

function expectOneElement(scope, elements) {
var msg = "expected to find exactly one element: " + scope.printFinders(scope.finders) + ', but found :' + elementsToString(elements);
expect(elements.length, msg).to.equal(1);
}
Selector.prototype.resolve = function(options) {

@@ -450,2 +455,14 @@ var self = this;

Selector.prototype.shouldHaveElement = function(fn, options) {
var self = this;
return this.addFinder({
find: function (elements) {
expectOneElement(self, elements);
elements.toArray().forEach(fn);
return elements;
}
}).shouldExist(options);
};
Selector.prototype.shouldNotHave = function(options) {

@@ -452,0 +469,0 @@ var resolveOptions = Options.remove(options, ['timeout', 'interval']);

5

package.json
{
"name": "browser-monkey",
"version": "1.17.1",
"version": "1.18.0",
"description": "reliable dom testing",

@@ -12,3 +12,2 @@ "main": "index.js",

"devDependencies": {
"chai": "2.2.0",
"chai-as-promised": "5.1.0",

@@ -25,3 +24,3 @@ "karma": "0.12.31",

"dependencies": {
"chai": "3.0.0",
"chai": "dereke/chai",
"debug": "2.2.0",

@@ -28,0 +27,0 @@ "jquery": "2.1.3",

@@ -271,2 +271,14 @@ # browser monkey

## shouldHaveElement
Assert that there is one element, and that it passes the expectations of a function.
```js
var promise = scope.shouldHaveElement(fn, [options]);
```
* `fn` a function that tests the element. The function is repeatedly called until it doesn't throw an exception, or until the timeout.
* `options.timeout` the timeout given for the element to pass the expectations, default 1000ms.
* `options.interval` - time between testing the dom (10ms)
## click

@@ -273,0 +285,0 @@

@@ -612,18 +612,25 @@ require('lie/polyfill');

it('eventually finds an element and asserts that it passes a predicate', function () {
var good1 = browser.find('.element').shouldHave({elements: function (elements) {
return $(elements).text() == 'a';
}});
var good2 = browser.find('.element').shouldHave(function (elements) {
return $(elements).text() == 'a';
var good1 = browser.find('.element').shouldHaveElement(function (element) {
expect(element.innerText).to.equal('a');
});
var bad1 = browser.find('.element').shouldHave({elements: function (elements) {
return $(elements).text() == 'b';
}, message: 'expected to have text b'});
eventuallyInsertHtml('<div class="element"></div><div class="element">a</div>');
var bad1 = browser.find('.multi').shouldHaveElement(function (element) {
expect(element.innerText).to.equal('b');
});
var bad2 = browser.find('.element').shouldHaveElement(function (element) {
expect(element.innerText).to.equal('b');
});
var element = $('<div class="element"></div>').appendTo(div);
eventuallyInsertHtml('<div class="multi"></div><div class="multi">b</div>');
setTimeout(function () {
element.text('a');
}, 30);
return Promise.all([
good1,
good2,
expect(bad1).to.be.rejectedWith('expected to have text b')
expect(bad1).to.be.rejectedWith('expected to find exactly one element'),
expect(bad2).to.be.rejectedWith("expected 'a' to equal 'b'")
]);

@@ -630,0 +637,0 @@ });

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