Gathering detailed insights and metrics for @s-ui/mockmock
Gathering detailed insights and metrics for @s-ui/mockmock
Gathering detailed insights and metrics for @s-ui/mockmock
Gathering detailed insights and metrics for @s-ui/mockmock
npm install @s-ui/mockmock
Typescript
Module System
Node Version
NPM Version
JavaScript (95.46%)
SCSS (2.23%)
TypeScript (1.89%)
HTML (0.14%)
CSS (0.14%)
Makefile (0.07%)
Smarty (0.05%)
Dockerfile (0.01%)
Sass (0.01%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
173 Stars
9,682 Commits
35 Forks
40 Watchers
58 Branches
78 Contributors
Updated on Jul 09, 2025
Latest Version
2.7.0
Package Id
@s-ui/mockmock@2.7.0
Unpacked Size
12.35 kB
Size
3.79 kB
File Count
7
NPM Version
10.8.2
Node Version
20.18.3
Published on
Jul 09, 2025
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
Mocking utilities for testing.
Centralize common solutions for common mocking concerns in JavaScript.
1npm install @s-ui/mockmock --save-dev
Mocks http
requests in node and XMLHttpRequest
requests in the browser.
1import {HttpMocker} from '@s-ui/mockmock' 2import axios from 'axios' 3 4// Mock any requests 5const mocker = new HttpMocker() 6mocker 7 .httpMock('http://fake.api.com') 8 .get('/my-service') 9 .reply({property: 'value'}, 200) 10 11// Make your requests 12axios 13 .get('http://fake.api.com/my-service') 14 .then(response => console.log(response)) // { property: 'value' }
Also available for import
1import HttpMocker from '@s-ui/mockmock/lib/http'
Since this library internally constructs the url of the original and the mocked request and then compares them, it's needed to create the mock request with the same parameter order than the original, if not, it will throw a 404.
The parameters of both petitions (original and mocked) don't have the same parameter order (err 404 thrown)
1mocker 2 .httpMock(...) 3 .get('/urlToAttack') 4 .query({ 5 search: 'value of the search', 6 working: false, 7 }) 8 ... 9 ... 10 11domain 12 .get('attacks_the_same_url_use_case') 13 .execute({ 14 working: false, 15 search: 'value of the search', 16 }) 17 ... 18 ...
The mocked and the original HTTP requests have to same parameter order
1mocker 2 .httpMock(...) 3 .get('/urlToAttack') 4 .query({ 5 search: 'value of the search', 6 working: true, 7 }) 8 ... 9 ... 10 11domain 12 .get('attacks_the_same_url_use_case') 13 .execute({ 14 search: 'value of the search', 15 working: true, 16 }) 17 ... 18 ...
It is important to clean tests before and after so you have a initial state non dependent.
Why? Sharing mutable state between components it is a bad idea.
Example:
1 2describe('abc', () => { 3 beforeEach(() => { 4 mocker.create() 5 }) 6 afterEach(() => { 7 mocker.restore() 8 }) 9 ... 10 it('xyz', () =>{ 11 ... 12 }) 13}) 14
The .reply(response, statusCode, headers)
method causes the 'fake' server to respond to any request not matched by another response with the provided data.
1mocker 2 .httpMock(...) 3 .get('/urlToAttack') 4 .query({ 5 search: 'value of the search', 6 working: true, 7 }) 8 .reply('{status: "ok"}', 200, {'Access-Control-Allow-Credentials': true}) 9 ... 10 ... 11 12const response = domain 13 .get('attacks_the_same_url_use_case') 14 .execute({ 15 search: 'value of the search', 16 working: true, 17 }) 18 19expect(response.data.status).to.equal('ok')
If you want to test what your use_case, function, etc is doing, probably you will need to check that based on the arguments provided to the function are transformed and as an output or side effect one or various requests
are done will a certain url
, body
, or headers
.
The .requestNTH(index)
method returns the nth request
mocked by the fake server so you can assert things like:
body
of the request is the one expected.headers
of the request are the expected.url
of the request is the one expected.requests
is the correct one.1mocker 2 .httpMock(...) 3 .get('/urlToAttack') 4 .query({ 5 search: 'value of the search', 6 working: true, 7 }) 8 .reply('{status: "ok"}', 200, {'Access-Control-Allow-Credentials': true}) 9 ... 10 ... 11 12const response = domain 13 .get('attacks_the_same_url_use_case') 14 .execute({ 15 search: 'value of the search', 16 working: true, 17 }) 18 19const request = mock.requestNTH(0) 20expect(request.body).to.be.equal('year=2030&doors=3&color=blue') 21expect(request.url).to.be.equal('https://.../urlToAttack') 22...
No vulnerabilities found.
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
packaging workflow detected
Details
Reason
Found 6/19 approved changesets -- score normalized to 3
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
dangerous workflow patterns detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
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
Reason
22 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