
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
chrome-stub
Advanced tools
Chrome API mocking library.
npm install chrome-stub
In most cases you will want to set this as a global at the top of your test file, because chrome is a global in your extension code.
chrome = require('chrome-stub')
To use the I18n library, chrome-stub loads a default messages.json file that has only one string in it, 'test' If you pass a string that does not exist, you will receive a blank string back.
If you want to load a different messages.json file, for example the one you use in your chrome extension then use the method below in your test file.
_locales/ru/messages.json
{
"test": {
"message": "Тест"
}
}
test.js
let path = require('path');
let config = path.resolve(process.cwd(), '_locales/ru/messages.json');
chrome.loadDefaults(config);
chrome.i18n.getMessage('test'); // Тест
All chrome APIs have been stubbed with sinon stub. You can define your own application-specific behavior of the stubs by following the sinon stub api. This allows you to define your behavior within your tests. For example:
// inside test
chrome.tabs.query.yields([{
id:0,index:0,windowId:0,highlighted:true,
active:true,pinned:false,url:'https://example.com',title:'example.com - Home',
favIconUrl:'https://example.com/favicon.ico',status:'complete',width:800,height:600
}]);
// do something that causes your code to call chrome.tabs.query, e.g.:
getFirstTab(function(tab){
// ...
// your code's callback is called with the value provided to yields()
});
Originally forked from sethmcl/chrome-mock
FAQs
Easily stub out chrome API calls for great test coverage
The npm package chrome-stub receives a total of 677 weekly downloads. As such, chrome-stub popularity was classified as not popular.
We found that chrome-stub demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.