{"id":"eyycheev/expect","name":"expect","scope":"eyycheev","platform":"roblox","description":"Mirrored from the Wally registry.","version":"3.14.0-rbx.2","latest":"3.14.0-rbx.2","versions":["3.14.0-rbx.0","3.14.0-rbx.1","3.14.0-rbx.2"],"license":"MIT","licenseRating":"safe","licenseCaveats":["The package archive does not include its license text; the license is declared in its manifest metadata."],"licenseVerified":false,"dependencies":{"eyycheev/jest-get-type":{"version":"^3.14.0-rbx.2","alias":"JestGetType"},"eyycheev/jest-matcher-utils":{"version":"^3.14.0-rbx.2","alias":"JestMatcherUtils"},"eyycheev/jest-message-util":{"version":"^3.14.0-rbx.2","alias":"JestMessageUtil"},"eyycheev/jest-snapshot":{"version":"^3.14.0-rbx.2","alias":"JestSnapshot"},"eyycheev/jest-util":{"version":"^3.14.0-rbx.2","alias":"JestUtil"},"jsdotlua/luau-polyfill":{"version":"^1.2.7","alias":"LuauPolyfill"},"jsdotlua/promise":{"version":"^3.5.2","alias":"Promise"},"jsdotlua/luau-regexp":{"version":"^0.2.1","alias":"RegExp"},"eyycheev/roblox-shared":{"version":"^3.14.0-rbx.2","alias":"RobloxShared"}},"integrity":"5805c3ee963d4974bcd5f19f1c1a588326c28b752491a9a9ad1df1252ec75a72","likes":0,"downloads":0,"install":"forest install eyycheev/expect","url":"https://forest.dev/p/roblox/eyycheev/expect","files":"https://api.forest.dev/ai/package/roblox/eyycheev/expect/files","readme":"# expect\n\nUpstream: https://github.com/facebook/jest/tree/v27.4.7/packages/expect\n\nThis package exports the `expect` function used in Jest. You can find its documentation in the [Jest documentation](https://roblox.github.io/jest-roblox-internal).\n\n---\n\n### :pencil2: Notes\n* :warning: Since `not` is a reserved keyword in Lua, we use `never`.\n* :warning: Several changes to matchers are made to maintain Lua-nativity. Corresponding changes are made to tests.\n    * `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.\n    * `toBeDefined` is omitted and `toBeUndefined` check for `nil` since there is no `undefined` in Lua.\n    * `toBeFalsy` and `toBeTruthy` checks for Lua falsy and truthy values, not JS ones\n    * `toHaveLength` checks using the Lua length operator by default, but instead checks for a `length` property if the object has one\n        * :warning: Length is only well defined for (non-sparse) array-like tables since the Lua `#` operator returns 0 for tables with key-value pairs\n    * `toHaveLength` does not accept functions, can't get the argument count of a function in Lua\n    * `toMatch` matches Lua string patterns or a LuauPolyfill `RegExp` whereas `toContain` matches exact substrings\n    * `toStrictEqual` is omitted, there is no strict equality in Lua\n    * The `Any` 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.\n        * If a typename string is passed in, the type is compared against the string.\n        * If a table is passed in, it checks that the object passed in is an instance (or a derived instance) of the provided prototype class.\n    ```lua\n    any(\"number\"):asymmetricMatch(1) -- true\n    any(\"number\"):toAsymmetricMatcher() -- \"Any<number>\"\n\n    any(ClassA):asymmetricMatch(ClassA.new()) -- true\n    any(ClassA):asymmetricMatch(ClassB.new()) -- false\n    any(ClassA):asymmetricMatch(ChildOfClassA.new()) -- true\n    ```\n    * `StringMatching` accepts Lua string patterns or a LuauPolyfill `RegExp`\n    * :warning: Although Jest has use cases where `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 for\n    * `toStrictEqual` 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 pattern\n* :warning: isError returns `true` 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 error\n* The throwing matchers (e.g. `toThrow()`) 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.\n* :warning: When writing custom matchers with `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.\n* :warning: Custom throwing matchers should throw errors that follow one of three patterns. Jest Roblox will attempt to `tostring` values that do not match these patterns and may result in undefined behavior.\n    * strings\n    * tables with a `message` key that has a string value\n    * objects with a `__tostring` metamethod\n* :warning: Currently, the spyMatchers have undefined behavior when used with jest-mock and function calls with `nil` arguments, this should be fixed by ADO-1395 (the matchers may work incidentally but there are no guarantees)\n","readmeTruncated":false}