
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
deep-assert
Advanced tools
Better deep-equals object expectations, supporting dynamic bottom-up assertions using any() and satisfies().
The most developer-friendly way to write assertions for large or complicated objects and arrays.
any() and satisfies() property matchers
npm install deep-assert
Let's say we want to check if an array of user objects matches our expectation, but we don't know what the id is gonna be, since it's a random ID. It's easy, using any().
import * as assert from "assert-deep"
assert.deepEquals(
// Actual value:
{
id: Math.random(),
name: "John Smith",
meta: {
isActive: true,
lastLogin: new Date("2019-04-29T12:31:00")
}
},
// Expectation:
{
id: assert.any(),
name: "John Smith",
meta: {
isActive: true,
lastLogin: new Date("2019-04-29T12:31:00")
}
}
])
Let's try the previous use case again, but this time we check that the id is a valid UUIDv4. We use the satisfies() helper function to create a custom assertion to be used within the object expectation.
import * as assert from "assert-deep"
const assertPositiveNumber = () => assert.satisfies(value => typeof value === "number" && value > 0)
assert.deepEquals(
// Actual value:
{
id: Math.random(),
name: "John Smith",
meta: {
isActive: true,
lastLogin: new Date("2019-04-29T12:31:00")
}
},
// Expectation:
{
id: assertPositiveNumber(),
name: "John Smith",
meta: {
isActive: true,
lastLogin: new Date("2019-04-29T12:31:00")
}
}
])
Normally deepEquals() will fail if there are properties on the tested object that don't exist on the expectation. We can use any() with the object spread operator to allow additional properties to be present.
deepEquals() will then only check the expected properties and ignore all other ones.
import * as assert from "assert-deep"
assert.deepEquals(
// Actual value:
{
id: Math.random(),
name: "John Smith",
meta: {
isActive: true,
lastLogin: new Date("2019-04-29T12:31:00")
}
},
// Expectation:
{
id: assert.any(),
name: "John Smith",
...assert.any()
}
])
You can call deepEquals() in a custom satisfies() as well. This way you can easily test recursive data structures, for instance.
import * as assert from "assert-deep"
const actual = { foo: {} }
actual.foo.parent = actual.foo
assert.deepEquals(actual, {
foo: assert.satisfies(foo => assert.deepEquals(foo, { parent: foo }))
})
MIT
FAQs
Better deep-equals object expectations, supporting dynamic bottom-up assertions using any() and satisfies().
We found that deep-assert 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
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.