
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Tapshot is a helper module for snapshot testing when you are using tools like tap and tape. Tapshot can be used to test any serializable object.
$ npm install --save-dev tapshot
As of V2, tapshot will not automatically add new snapshots or snapshot files. You'll need to pass the 'update' option to save them. See Updating Snapshots for how to do this.
tap
object or function: A tap class that has the equal
and pass
methods. If you're not setting name
in options
, this also needs to contain a name, which will be provided if you use it within a named subtestobject
any: The object that you want to snapshot. This can be any serializable object. If it is a non-standard object, a serializer
must be provided in options
.options
object: The options to run the test with. These are all optional:
name
string: The name for the snapshotfile
string: The location of the snapshot file you wish to useserializer
string or function: The serializer for the object provided if it is a non-standard object. If passed as a string, it will call that method on the object, if passed as a function, the funtion will be called with the object as the only argument.update
boolean: If set to true, the snapshot for this test will be updatedThis will return a tapshot instance that is configured to use the options passed in as defaults. This instance can be used the same as above.
options
object: The options to configure the tapshot instance with. These are optional:
file
string: The location of the snapshot file you wish to useupdate
boolean: If set to true, the snapshots will be updatedIf you change the structure of the object being snapshotted, you will need to update your snapshots. There are 3 ways to do this:
update
OptionSet the update
option when calling tapshot. Like so:
tapshot(t, `console.log('this is a string of text')`, {update: true});
This will only update the snapshot for that specific test.
update
Configuration OptionSet the update
option when calling tapshot.configure()
. Like so:
tapshot.configure({update: true});
This will update the snapshots for any tests that use that instance.
const tap = require(`tap`);
const tapshot = require(`tapshot`);
tap.test(`Generated code is as expected`, (t) => {
tapshot(t, `console.log('this is a string of text')`);
t.end();
});
const tap = require(`tap`);
const tapshot = require(`tapshot`);
tap.test(`Generated code is as expected`, (t) => {
tapshot(t, `console.log('this is a string of text')`, {name: 'generated-code'});
t.end();
});
const tap = require(`tap`);
const tapshot = require(`tapshot`).configure({update: true});
tap.test(`Generated code is as expected`, (t) => {
tapshot(t, `console.log('this is a string of text')`);
t.end();
});
MIT © Luke Bonaccorsi
FAQs
Snapshot assertions for TAP
The npm package tapshot receives a total of 7 weekly downloads. As such, tapshot popularity was classified as not popular.
We found that tapshot 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
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.