
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@jsdotlua/expect
Advanced tools
Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/expect
This package exports the expect
function used in Jest. You can find its documentation in the Jest documentation.
not
is a reserved keyword in Lua, we use never
.toBeInstanceOf
can be used to check that the received value is an instance (or a derived instance) of the expected value, where the expected value is a prototype class. The matcher will error if either the received or expected value isn't an object.toBeDefined
is omitted and toBeUndefined
check for nil
since there is no undefined
in Lua.toBeFalsy
and toBeTruthy
checks for Lua falsy and truthy values, not JS onestoHaveLength
checks using the Lua length operator by default, but instead checks for a length
property if the object has one
#
operator returns 0 for tables with key-value pairstoHaveLength
does not accept functions, can't get the argument count of a function in LuatoMatch
matches Lua string patterns or a LuauPolyfill RegExp
whereas toContain
matches exact substringstoStrictEqual
is omitted, there is no strict equality in LuaAny
matcher is used to match any instance of a type or object given a constructor function. Lua doesn't have constructors for primitive types. Our deviation for this matcher therefore accepts either a typename string (e.g. "number", "boolean") or a table representing a prototype class, and will error otherwise.
any("number"):asymmetricMatch(1) -- true
any("number"):toAsymmetricMatcher() -- "Any<number>"
any(ClassA):asymmetricMatch(ClassA.new()) -- true
any(ClassA):asymmetricMatch(ClassB.new()) -- false
any(ClassA):asymmetricMatch(ChildOfClassA.new()) -- true
StringMatching
accepts Lua string patterns or a LuauPolyfill RegExp
toHaveProperty
is used to detect the existence of a property as undefined
, we should never try to use toHaveProperty
with nil
as the property to check fortoStrictEqual
does not check for array sparseness or undefined
properties like in Javascript. Its only difference from toEqual
is that it also applies a Lua type/class check based on the Lua prototypical metatable inheritance patterntrue
for string and table types since we don't have a designated error type in Lua and these two types are what can be used to trigger an errortoThrow()
) will print out stack traces for ALL types (except nil
) that are thrown whereas in Javascript the stack trace is only printed if you error with an Error type. In other words, executing a toThrow
matcher on something like throw ''
in Javascript will not end up printing the stack trace but doing so with error("")
will print the stack trace for our Lua equivalent.expect.extend()
, a first argument self
is needed to receive the matcherContext
. It can be left empty with _
if the matcherContext
is not be needed.tostring
values that do not match these patterns and may result in undefined behavior.
message
key that has a string value__tostring
metamethodnil
arguments, this should be fixed by ADO-1395 (the matchers may work incidentally but there are no guarantees)FAQs
Unknown package
The npm package @jsdotlua/expect receives a total of 4 weekly downloads. As such, @jsdotlua/expect popularity was classified as not popular.
We found that @jsdotlua/expect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.