
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Easy Choo testing for Choo v5, v6 and v7.
$ npm install choo-test --save-dev
Here is an example using Mochify as the test runner:
var assert = require('assert');
var choo = require('choo');
var html = require('choo/html');
var test = require('choo-test');
function model(state, emitter) {
state.text = 'Test';
emitter.on('change', () => {
state.text = 'Changed';
emitter.emit('render');
});
}
function view(state, emit) {
return html`<button onclick=${function () {
emit('change');
}}>${state.text}</button>`;
}
describe('choo-app', function () {
var restore;
var app;
beforeEach(function () {
app = choo();
app.use(model);
app.route('/', view);
});
afterEach(function () {
restore();
});
it('changes the button text on click', function (done) {
restore = test.start(app);
test.fire('button', 'click');
test.onRender(function () {
assert.equal(test.$('button').innerText, 'Changed');
done();
});
});
});
This module is a collection of helper functions. Each of them can be used separately.
When you use the start
function to start your Choo app, it wraps and appends
the application to a div
tag in the document.body
. When calling the
returned restore
function, the DOM node is removed again.
The onRender
function creates a MutationObserver and invokes the given
callback if any change in the DOM tree happens.
Global window events are captured and unregistered when calling restore()
.
$(selector[, scope])
: Find a DOM element using querySelector
. scope
must be a DOM node to search and defaults to document
.$$(selector[, scope])
: Find all DOM element using querySelectorAll
.
scope
must be a DOM node to search and defaults to document
.fire(selector, event[, args])
: Fire an event using bean.fire.onRender([nodeOrSelector, ]fn)
: Register a function to invoke after the
next DOM mutation occurred. If only a function is given, the entire
document
is observed. If no mutation occurs within 1500 ms, a timeout error
is thrown.start(app)
: Creates a div
tag and append it to document.body
, then
starts the given Choo app and attaches the returned tree to the div
node.
Returns a restore()
function which remove the div
node from the body.Use the Sinon.js fake server for XHR testing. If you're
using the xhr library, you have to initialize the XMLHttpRequest
implementation like this:
sandbox = sinon.sandbox.create({
useFakeServer: true
});
sandbox.stub(xhr, 'XMLHttpRequest', sandbox.server.xhr);
MIT
1.0.0
BREAKING: The codebase was upgraded to ES5.
Choo v7 was added to the supported versions in peerDependencies
. With this
release, choo-test
is compatible with v5, v6 and v7.
7ff4e9d
State choo compatibility, update URL and remove badgeb85587b
Switch to @studio/eslint-config
4914419
Upgrade eslint to v64603617
Upgrade Studio Changes2d7122d
Upgrade choo to v78289a74
Update mochifyReleased by Maximilian Antoni on 2019-09-12.
FAQs
Easy choo app unit testing
The npm package choo-test receives a total of 0 weekly downloads. As such, choo-test popularity was classified as not popular.
We found that choo-test 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
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.