Gathering detailed insights and metrics for jasmine-where
Gathering detailed insights and metrics for jasmine-where
Gathering detailed insights and metrics for jasmine-where
Gathering detailed insights and metrics for jasmine-where
@micromint1npm/porro-nulla-natus
Save [CouchDB sequence #s](http://docs.couchdb.org/en/2.1.1/api/database/changes.html#changes-feeds) to a configurable backend. This allows you to resume CouchDB replication from the point where you left off.
@odczynflnpm/et-nihil-enim
Get index i.e. 0,1,2,... of the character where a word must be broken given it must be wrapped within a certain length of spaces.
npm install jasmine-where
Typescript
Module System
NPM Version
JavaScript (95.96%)
CSS (4.04%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2 Stars
35 Commits
1 Forks
1 Watchers
1 Branches
1 Contributors
Updated on Oct 09, 2014
Latest Version
0.0.12
Package Id
jasmine-where@0.0.12
Size
29.26 kB
NPM Version
1.4.21
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
jasmine-where has been superseded by where.js
Provides a where()
clause for data-table support to the
Jasmine BDD test framework, similar to
Cucumber's scenario-outline
Examples
or Spock's
where blocks.
Partly inspired by:
npm install jasmine-where
git clone https://github.com/dfkaye/jasmine-where.git
Including or requiring jasmine-where
adds a where()
method to the global
namespace, for example:
require('jasmine-where');
where === global.where === jasmine.getEnv().where;
<script -- jasmine 1 or 2 scripts first -->
<script src="../jasmine-where.js"></script>
where === window.where === jasmine.getEnv().where;
Easier to modify this
it('description', function () {
where(function(){/***
a | b | c
1 | 2 | 2
4 | 3 | 4
6 | 6 | 6
***/
expect(a + b)).toBe(c);
});
});
than this:
it('description', function () {
[[1, 2, 2],
[4, 3, 4],
[6, 6, 6]].forEach(function(row, r, rows) {
expect(Number(row[0]) + Number(row[1])).toBe(Number(row[2]));
});
});
Borrowing from Richard Rodger's mstring,
where()
accepts a function and inspects its string value, converts the triple-
commented data-table into an array of values, uses the labels as variables or
symbols in a new Function().
Each where()
clause works best with only one expectation clause at the moment
(still debating whether it's worth supporting multiple expects in a single
where()
).
Data tables must contain at least two rows, the first row containing symbols to be used as variables in the expectation, whereas the remaining rows must contain data for each symbol.
For example:
it('should pass with correct data and expectation', function () {
where(function(){/***
a | b | c
1 | 2 | 2
4 | 3 | 4
6 | 6 | 6
***/
expect(Math.max(a, b)).toBe(c);
});
});
Tables may also contain left and right borders, similar to Cucumber and Fit:
it('should pass with left and right table borders', function () {
where(function(){/***
| a | b | c |
| 1 | 2 | 2 |
| 4 | 3 | 4 |
| 6 | 6 | 6 |
***/
expect(Math.max(a, b)).toBe(c);
});
});
Supports Math.max(a, b)
to avoid re-typing Math.max(Number(a), Number(b))
.
Everything can use toBe()
(strict equality) - no need to rely on toMatch()
.
However, where Math
is involved there is usually an octal, signed, comma, or
precision bug waiting. All but precision are handled automatically; however,
you can get precision into your tests by adding another column, as seen in the
test created to verify numeric conversions work:
where(function(){/***
a | b | c | p
0 | 1 | 1 | 1
0.0 | 1.0 | 1 | 1
-1 | +1 | 0 | 1
+1.1 | -1.2 | -0.1 | 2
08 | 08 | 16 | 2
6 | 4 | 10.0 | 3
8.030 | -2.045 | 5.985 | 4
1,000.67 | 1345 | 2345.67 | 6
***/
// using precisions for famous 5.985 vs 5.98499999999999999999999999 bugz
var s = (a + b).toPrecision(p) // toPrecision() returns a string
expect(+s).toBe(c) // but prefixed '+' uses implicit conversion to number.
});
A passing where()
clause has no effect on the usual jasmine output.
When an expectation fails, the data-table labels plus the row of values for the
current expectation are added to the current failing item. Every failed
expectation in a where()
clause will appear as:
[a | b | c] :
[1 | 2 | x] (Expected 2 to be 'x'.)
You can capture the generated data table, including the labels, as the return
value of the where
clause for post-where assertions:
it('returns data', function () {
var results = where(function(){/***
a | b | c
1 | 1 | 1
1 | 2 | two
3 | 2 | 3
5 | 3 | 5.01
***/
// within where
expect(Math.max(a, b)).toBe(c);
});
// inspect results returned by where()
expect(results[2][2]).toBe('two');
});
In working this out, I found I needed a way to intercept the results in where
tests that were expected to fail. I've worked out
jasmine-intercept to handle that.
It is included in the node_modules directory of this repo (if you're viewing on
github).
Current implementation runs in both jasmine 1.3.1 and jasmine 2.0.0-rc3.
Using jasmine-node which uses
jasmine-1.3.1
internally. Run that with
jasmine-node --verbose ./test/node-suite.js
or simply
npm test
The jasmine2 browser test page is viewable on rawgit.
Using Toby Ho's MAGNIFICENT testemjs to
drive tests in multiple browsers for jasmine-2.0.0 (see how to
hack testem for jasmine 2), as well
as jasmine-node. The testem.json
file uses the standalone test page above,
and also uses a custom launcher for jasmine-node (v 1.3.1).
In addition, the following command uses a custom launcher for jasmine-node
in
testem
:
testem -l j
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More