
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
#chai-diff
Adds expectations to chai which compare strings or objects using jsdiff.
expect(value).differentFrom(another, options)
expect(value).not.differentFrom(another, options)
expect(value).to.be.differentFrom(another, options)
expect(value).not.to.be.differentFrom(another, options)
This will compare two strings or convert two objects to JSON strings and then compare them. One oddity is that the base form expects the objects to be different and you will generally use the .not.differentFrom form.
The options object is optional and can have the following options:
showSpace [false] Whether to convert whitespace to visible Unicode characters in output.relaxedSpace [false] Whether to normalise whitespace before comparing strings. This:
context [10] How many lines of context to show on each side of a differencenpm install chai-diff --save-dev
In your specs, add:
chai.use(require('chai-diff'));
See chai-diff.spec.js for an example
Download the chai-diff.js file and add it to your main. Then in your test do something like:
define(['chai', 'chai-diff', ...], function(chai, chaiDiff, ...) {
chai.use(chaiDiff);
describe(...);
});
Finally, if neither CommonJS nor AMD is detected, a global varialbe chaiDiff is created and can be used with:
<script src="chai.js"></script>
<script src="diff.js"></script>
<script src="chai-diff.js"></script>
<script>
chai.use(chaiDiff);
...
</script>
See test.html for an example
This is useful if:
Further improvements:
FAQs
Adds expectations to chai which compare strings or objects using diff.
The npm package chai-diff receives a total of 2,866 weekly downloads. As such, chai-diff popularity was classified as popular.
We found that chai-diff 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.