Gathering detailed insights and metrics for ember-sinon-qunit
Gathering detailed insights and metrics for ember-sinon-qunit
Gathering detailed insights and metrics for ember-sinon-qunit
Gathering detailed insights and metrics for ember-sinon-qunit
npm install ember-sinon-qunit
Typescript
Module System
Node Version
NPM Version
TypeScript (49.13%)
JavaScript (42.53%)
HTML (7.66%)
CSS (0.49%)
Handlebars (0.19%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
58 Stars
2,172 Commits
30 Forks
4 Watchers
23 Branches
21 Contributors
Updated on Jan 27, 2025
Latest Version
7.5.0
Package Id
ember-sinon-qunit@7.5.0
Unpacked Size
17.54 kB
Size
6.21 kB
File Count
16
NPM Version
10.7.0
Node Version
20.15.1
Published on
Jul 17, 2024
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
3
46
This addon integrates sinon
& ember-qunit
.
Why not simply use sinon
alone?
sinon
does not handle cleanup of ember-qunit
tests. While sinon
sandboxes itself, it's up to the user to
consistently clean up sinon
after each test. ember-sinon-qunit
automatically
restores sinon
's state to ensure nothing is leaked between tests. All spies/stubs created
will be automatically restored to their original methods at the end of each test.
ember install ember-sinon-qunit
sinon
is a peerDependency of this addon, so install it with your favorite package manager as well, e.g. yarn add -D sinon
.
To use, import the setup method into your tests/test-helper.js
file and execute it.
1import { setApplication } from '@ember/test-helpers'; 2import { start } from 'ember-qunit'; 3import Application from '../app'; 4import config from '../config/environment'; 5import setupSinon from 'ember-sinon-qunit'; 6 7setApplication(Application.create(config.APP)); 8 9setupSinon(); 10 11start();
This will automatically wire-up sinon
's setup & restoration to QUnit's testStart
and testDone
respectively.
sinon
Within TestsIn each test you are able to access sinon
via the sinon
object available as an import in your tests:
1import { module } from 'qunit'; 2import { test } from 'ember-qunit'; 3import sinon from 'sinon'; 4 5module('Example test', function (hooks) { 6 hooks.beforeEach(function () { 7 this.testStub = sinon.stub(); 8 }); 9 10 test('sinon is wired up correctly', function (assert) { 11 this.testStub(); 12 13 assert.ok(this.testStub.calledOnce, 'stub was called once'); 14 }); 15 16 test('sinon state restored after every test run', function (assert) { 17 assert.ok(this.testStub.notCalled, 'stub cleaned up after each test run'); 18 }); 19});
The sinon
object's state is automatically self-contained to each specific test, allowing you to
safely create mocks for your tests without worrying about any overrides leaking between each test.
@action
decoratorThe @action
decorator is used with methods to bind them to the this
of the class. The @action
does this by wrapping the method in a property with the getter
of the property returning the
original method bound to this
. That means when you wish to stub or spy the method, you have to treat it as a
property not a method.
1let stubAction = sinon.stub(service, 'methodToStub').get(function () { 2 return null; 3}); 4 5let spyAction = sinon.spy(service, 'methodToStub', ['get']); 6 7assert.ok(stubAction.get.calledOnce); 8assert.ok(spyAction.get.calledOnce);
ember-sinon-qunit
Read this post to learn more about the overhaul of this package. |
---|
The above functionality replaces previous features within ember-sinon-qunit
,
as well as the sister addons ember-sinon-sinoff
and ember-sinon-sandbox
.
Below, you will find simple instructions for migrating from each of these feature sets to the new patterns.
sinon
5+setupSinon
.sinon.restore()
. It won't hurt to leave them, but they are redundant now!sinon
setupSinon
.sinon.createSandbox()
. Anywhere you used the sandbox
object returned by this method,
you can now use sinon
directly. See the sinon
Migration Guide
for more information.restore()
calls for your sandboxes.ember-sinon-qunit
ember-qunit
test import:
import { test } from 'qunit';
setupSinon
.ember-sinon-sinoff
or ember-sinon-sandbox
import sinon from 'sinon';
within each test that currently uses a sandbox
.this.sandbox
with the imported sinon
object.setupSinonSinoff
/setupSinonSandbox
from your tests.setupSinon
.Or, if you'd like to save some effort, try the following codemod ember-sinon-qunit-codemod
:
1cd my-ember-app-or-addon 2npx ember-sinon-qunit-codemod tests
See the Contributing guide for details.
This project is licensed under the MIT License.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
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
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
18 existing vulnerabilities detected
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