Socket
Socket
Sign inDemoInstall

chai-nightwatch

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-nightwatch - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

68

lib/chai/assertion.js

@@ -8,6 +8,3 @@ /*!

const config = require('./config');
module.exports = function (_chai, util) {
const AssertionError = _chai.AssertionError;
const flag = util.flag;

@@ -24,4 +21,3 @@

*/
function Assertion (promise, msg, stack) {
flag(this, 'ssfi', stack || arguments.callee);
function Assertion (promise, msg) {
flag(this, 'promise', promise);

@@ -31,24 +27,2 @@ flag(this, 'message', msg);

Object.defineProperty(Assertion, 'includeStack', {
get: function() {
console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
return config.includeStack;
},
set: function(value) {
console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
config.includeStack = value;
}
});
Object.defineProperty(Assertion, 'showDiff', {
get: function() {
console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
return config.showDiff;
},
set: function(value) {
console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
config.showDiff = value;
}
});
Assertion.addProperty = function (name, fn) {

@@ -93,40 +67,6 @@ util.addProperty(this.prototype, name, fn);

Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
const ok = util.test(this, arguments);
if (true !== showDiff) {
showDiff = false;
}
if (true !== config.showDiff) {
showDiff = false;
}
if (!ok) {
const msg = util.getMessage(this, arguments);
const actual = util.getActual(this, arguments);
throw new AssertionError(msg, {
actual: actual
, expected: expected
, showDiff: showDiff
}, (config.includeStack) ? this.assert : flag(this, 'ssfi'));
}
Assertion.prototype.assert = function (opts) {
const {assertion} = this;
assertion.assert(opts);
};
/*!
* ### ._obj
*
* Quick reference to stored `actual` value for plugin developers.
*
* @api private
*/
Object.defineProperty(Assertion.prototype, '_obj', {
get: function () {
return flag(this, 'promise');
},
set: function (val) {
flag(this, 'promise', val);
}
});
};

91

lib/chai/core/assertions.js

@@ -46,2 +46,3 @@ /*!

flag(this, chain, true);
const isComponent = flag(this, 'component') === true;

@@ -57,7 +58,17 @@ return new Proxy(this, {

}
if (prop === 'deferred') {
if (prop === 'deferred' || isComponent) {
return;
}
if (prop === 'then' || prop === 'catch') {
const promise = flag(this, 'promise');
if (promise instanceof Promise) {
return promise[prop];
}
return;
}
throw new Error(`Unknown property: "${prop}". Please consult docs at: http://nightwatchjs.org/api.`)

@@ -131,2 +142,78 @@ }

/**
* ### .nested
*
* Enables dot- and bracket-notation in all `.property` and `.include`
* assertions that follow in the chain.
*
* expect({a: {b: ['x', 'y']}}).to.have.nested.property('a.b[1]');
* expect({a: {b: ['x', 'y']}}).to.nested.include({'a.b[1]': 'y'});
*
* If `.` or `[]` are part of an actual property name, they can be escaped by
* adding two backslashes before them.
*
* expect({'.a': {'[b]': 'x'}}).to.have.nested.property('\\.a.\\[b\\]');
* expect({'.a': {'[b]': 'x'}}).to.nested.include({'\\.a.\\[b\\]': 'x'});
*
* `.nested` cannot be combined with `.own`.
*
* @name nested
* @namespace BDD
* @api public
*/
Assertion.addProperty('nested', function () {
flag(this, 'nested', true);
});
/**
* ### .own
*
* Causes all `.property` and `.include` assertions that follow in the chain
* to ignore inherited properties.
*
* Object.prototype.b = 2;
*
* expect({a: 1}).to.have.own.property('a');
* expect({a: 1}).to.have.property('b');
* expect({a: 1}).to.not.have.own.property('b');
*
* expect({a: 1}).to.own.include({a: 1});
* expect({a: 1}).to.include({b: 2}).but.not.own.include({b: 2});
*
* `.own` cannot be combined with `.nested`.
*
* @name own
* @namespace BDD
* @api public
*/
Assertion.addProperty('own', function () {
flag(this, 'own', true);
});
/**
* ### .ordered
*
* Causes all `.members` assertions that follow in the chain to require that
* members be in the same order.
*
* expect([1, 2]).to.have.ordered.members([1, 2])
* .but.not.have.ordered.members([2, 1]);
*
* When `.include` and `.ordered` are combined, the ordering begins at the
* start of both arrays.
*
* expect([1, 2, 3]).to.include.ordered.members([1, 2])
* .but.not.include.ordered.members([2, 3]);
*
* @name ordered
* @namespace BDD
* @api public
*/
Assertion.addProperty('ordered', function () {
flag(this, 'ordered', true);
});
/**
* ### .any

@@ -133,0 +220,0 @@ *

@@ -9,3 +9,2 @@ /*!

const flag = require('./flag');
const config = require('../config');

@@ -73,8 +72,2 @@ // Check whether `__proto__` is supported

const assert = function assert() {
const old_ssfi = flag(this, 'ssfi');
if (old_ssfi && config.includeStack === false) {
flag(this, 'ssfi', assert);
}
const result = chainableBehavior.method.apply(this, arguments);

@@ -81,0 +74,0 @@

@@ -8,4 +8,2 @@ /*!

const config = require('../config');
/**

@@ -35,12 +33,4 @@ * ### .addMethod (ctx, name, method)

*/
const flag = require('./flag');
module.exports = function (ctx, name, method) {
ctx[name] = function () {
const old_ssfi = flag(this, 'ssfi');
if (old_ssfi && config.includeStack === false) {
flag(this, 'ssfi', ctx[name]);
}
const result = method.apply(this, arguments);

@@ -47,0 +37,0 @@

@@ -9,3 +9,2 @@ /*!

getActual: require('./getActual'),
objDisplay: require('./objDisplay'),
flag: require('./flag'),

@@ -16,5 +15,2 @@ transferFlags: require('./transferFlags'),

addChainableMethod: require('./addChainableMethod')
};
};
{
"author": "Andrei Rusu <andrei.rusu@beatfactor.net>",
"author": "Andrei Rusu",
"name": "chai-nightwatch",
"description": "",
"license": "MIT",
"version": "0.4.1",
"version": "0.4.2",
"repository": {
"type": "git",
"url": "https://github.com/beatfactor/chai"
"url": "https://github.com/nightwatchjs/chai-nightwatch"
},
"main": "./index",
"scripts": {
"test": "make test"
},
"engines": {
"node": ">= 8.0.0"
"node": ">= 12.0.0"
},
"dependencies": {
"assertion-error": "1.0.0",
"deep-eql": "0.1.3"
},
"devDependencies": {
"mocha": "^6.2.2"
"assertion-error": "1.1.0"
}
}
## Chai expect adapter for Nightwatch.js
This is a modified version of Chai to support Nightwatch.js asserts.
This is a trimmed down version of Chai to support Nightwatch.js related assertions.

@@ -16,3 +16,3 @@ Chai is a BDD / TDD assertion library for [node](http://nodejs.org) and the browser that

Copyright (c) 2015 Andrei Rusu <andrei.rusu@beatfactor.net>
Copyright (c) 2015 Andrei Rusu

@@ -19,0 +19,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

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