Gathering detailed insights and metrics for jasmine-scope-check
Gathering detailed insights and metrics for jasmine-scope-check
Gathering detailed insights and metrics for jasmine-scope-check
Gathering detailed insights and metrics for jasmine-scope-check
Archived! This only works with Jasmine 1, which is no longer a productive, state-of-the-art JS testing framework anymore. | Static code analysis catches a lot of accidental globals, but if the assignment happens indirectly, you'd have to run the code to find what's wrong. This is what jasmine-scope-check does.
npm install jasmine-scope-check
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (99.85%)
HTML (0.15%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Stars
18 Commits
1 Forks
3 Watchers
2 Branches
10 Contributors
Updated on Jan 28, 2023
Latest Version
1.0.2
Package Id
jasmine-scope-check@1.0.2
Size
128.19 kB
NPM Version
3.3.12
Node Version
5.2.0
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
This Jasmine extension is intended for browser code.
It runs between each spec and verifies that the global scope (window
object) was not changed by comparing its state
before and after the spec, detecting additions, modifications and deletions of window
properties.
Static code analysis catches a lot of accidental globals, but if the assignment happens indirectly, you'd have to run the code to find what's wrong. This is what jasmine-scope-check does.
jasmine-scope-check is for you if your code runs in a context out of your control. For example:
Install the scope check before running any specs:
new JasmineScopeCheck({
globalObject: window
}).install(beforeEach, afterEach);
Used like this, a default white list is used that fits a typical browser-Jasmine environment.
See the demo
directory for a real-world example.
The following properties can be passed to the JasmineScopeCheck
constructor:
globalObject
(default = window
): The object to check for changes.expect
(default = globalObject.expect
): Jasmine's expect
function.whiteList
(default = []
): An array of strings and/or regular expressions that specify property paths that may
change without causing broken expectations. A property path consists of hierarchical property names from top to
bottom, separated by dots.maxRecursionDepth
(default = 4
): Properties that are this number of steps removed from globalObject
are no
longer checked for changes, which is necessary for performance.useDefaultWhiteList
(default = true
): By setting this to false
, only whiteList
is used for ignoring properties
that may be changed legitimately. Otherwise, the default white list is used in conjunction with whiteList
.In an environment where mechanisms such as Jasmine 2's global beforeEach()
and afterEach()
are not available, the
scope check can be invoked manually:
var myScope = {};
var scopeCheck = new JasmineScopeCheck({
globalObject = myScope
});
// Change things in myScope.
scopeCheck.compareGlobalSnapshotWithReality();
// Changes are tracked in: scopeCheck.addedProperties, scopeCheck.changedProperties, scopeCheck.removedProperties.
// Before doing some more changes that should be tracked independently, reset the state:
scopeCheck.reset();
dist/jasmine-scope-check.js
if you're not afraid of library conflicts (see TODO below).dist/jasmine-scope-check.min.js
if for whatever reason your test helpers need to be smaller.jasmine-scope-check.js
if you bring the dependencies (lodash, deep-diff) yourself.dist/*.js
, which may lead to conflicts with other versions of lodash and
deep-diff.# Clone the repo.
git clone git@github.com:findologic/jasmine-scope-check.git
# Install dependencies from NPM.
npm install
# Make sure that the gulp command is installed globally.
npm install -g gulp
# Run builds and tests to check that everything works.
gulp
# (optional) Build documentation.
gulp docs
install()
method to wrap around all specs for comprehensive scope check coverage.(The MIT License)
Copyright (c) 2016 FINDOLOGIC GmbH
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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 2/8 approved changesets -- score normalized to 2
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
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