You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* APT-328 - Implement jest.spyOn (#382)
## Problem
[APT-328](https://roblox.atlassian.net/browse/APT-328)
## Solution
Align and complete implementation of `spyOn` function
## Testing
Aligned a number of tests, including further tests for already-ported
logic.
* #nojira Fix misconception in comment (#383)
* UIBLOX-667: Update jest mock type (#385)
The type in the export is incorrect
See here
https://github.com/Roblox/jest-roblox-internal/blob/master/src/jest-runtime/src/init.lua#L2450
Updating and bumping to be moduleScript instead of string
---------
* APT-1452 dom to fs path resolution in jest-runner for jest-vscode reconciler (#373)
* Release 3.7.0 (#386)
Updating changelog and bumping release version for 3.7.0. Needed for the vscode extension.
* Mock task wait (#388)
Mocking task.wait directly in jest as per suggestion of @LordOfSpelunky
* Configure Jest to use the Registry (#390)
## Problem
Projects using the registry cannot consume new versions of Jest
## Solution
Configre Jest to use the registry
## Testing
Describe how the solution was tested (ideally unit tests). If done
manually, describe the process and outcome.
## Checklist (remove if not applicable)
- [ ] For new modules, has a README.md file with notes about the
translation
- [ ] All deviations are notated in code with `-- ROBLOX deviation:
comment`
- [ ] Translated files include a comment with a link to the upstream
file
* #nojira fix mismatched test paths between reporter and runner (#395)
* v3.8.1 (#396)
* APT-597 mock lua globals (#397)
## Problem
The `spyOn` function does not currently work with Lua globals because
those tables are not mockable in the usual way.
## Solution
Adds `jest.globalEnv` which can be used with `spyOn` to mock Lua globals
in a test environment. Allows access to the unmocked globals as members
too.
## Testing
Added new unit test cases to cover API surface.
## Checklist (remove if not applicable)
- [x] For new modules, has a README.md file with notes about the
translation
- [x] All deviations are notated in code with `-- ROBLOX deviation:
comment`
- [x] Translated files include a comment with a link to the upstream
file
* APT-1775 Optimistic protected instance property indexing (#398)
## Problem
Jest assumes that all properties listed in the Roblox API are safe to
index. This is not true when encountering properties that are only
accessible to privileged code while Jest is running in a less privileged
context, or when otherwise dealing with properties that have the
potential to error on index.
## Solution
Hide details of the Roblox API inside of RobloxInstance, and instead
only expose 'safe' APIs that protect around all instance reads and
writes, and expose only the properties which are accessible with the
script's current capabilities.
## Testing
Unit tests and snapshots.
* APT-1023 APT-1778 Update links and fix static assets (#400)
Moved all jest docs links to point to the 27.x archived version of the
jest docs and updated static assets correctly the docusaurus way.
* APT-1808 update manifests, release 3.9.0 (#402)
* v3.9.1, fix type in runtime (#403)
* APT-1797 More helpful error when requiring `JestGlobals` outside a test environment (#405)
## Problem
When Jest 2 users are in the midst of updating to Jest 3, they might
attempt to pull in Jest 3 globals.
https://roblox.slack.com/archives/C04N86WJA4R/p1721837297468429?thread_ts=1721815127.913289&cid=C04N86WJA4R
## Solution
Update the JestGlobals error to include a tip about mixing Jest 2 and
Jest 3.
## Testing
Unit tests.
* APT-1523 fallback to loadstring if loadmodule not enabled (#392)
* Setup JestMockGenv for publish
* Fix require paths
* APT-1766 Better error snapshots (#401)
## Problem
When an error with a stack trace is saved to a snapshot, superficial or
unrelated changes in the codebase can cause the snapshot test to fail,
because line numbers or file names in the stack trace can change. In
particular, this occurs for some of Jest's own snapshot tests.
## Solution
Introduce a new `redactStackTrace` function to `RobloxShared` which
replaces stack traces with fixed-size dummy contents, similar to how
`pruneDeps` cleans up stack trace lines from stack traces today. The
final result is intended to be formatted exactly like a valid stack
trace, except it is guaranteed to be completely decoupled from the
actual stack trace it replaces, allowing for the stack trace to be
snapshotted safely.
Use `redactStackTrace` in the flaky snapshot tests in
`errorParsing.spec` which were causing problems before.
## Testing
Unit tests and snapshots.
* APT-1805 add JestBenchmark to the documentation page (#406)
* APT-1837 Protect against bad plugin table reads (#407)
## Problem
When adding `pretty-format` plugins, it's possible to accidentally miss
adding the plugin to the `prettyFormat.plugins` table. However, other
code might still depend on the plugin being accessible from that table,
which will silently fail.
## Solution
Add an `__index` metatable which throws an error, so that when a plugin
can't be found in the table, the issue is escalated right away.
## Testing
Unit test.
## Checklist
- [x] All deviations are notated in code with `-- ROBLOX deviation:
comment`
* APT-1826 Stabilise RobloxInstance "serialises Folder" test. (#408)
## Problem
RobloxInstance "serialises Folder" test should not fail when source code
in RobloxInstance changes.
## Solution
Copy a different folder of code into the tests directory as an
unchanging target. Then, point the test at that.
## Testing
Snapshot tests test themselves 🤠
* Release 3.10.0 (#411)
* Point to right directory for jest-mock-genv
Co-authored-by: jeparlefrancais <35781636+jeparlefrancais@users.noreply.github.com>
* Run yarn install
* bump rbx-aged-tool (#412)
https://github.com/Roblox/rbx-aged-tool/releases/tag/5.7.10
* APT-1913 Inject alike types (#409)
## Problem
Right now, `spyOn` injects a table object when spying on objects. This
table has a different type and overall behaves quite differently from
the function it's meant to replace, and there's only so much we can do
to disguise it in Luau.
## Solution
Move away from injecting 'mock objects'. Instead, inject 'alike types'
wherever possible - in this case, inject a function when spying on a
function.
## Testing
Unit & snapshot tests.
## Checklist (remove if not applicable)
- [x] For new modules, has a README.md file with notes about the
translation
- [x] All deviations are notated in code with `-- ROBLOX deviation:
comment`
- [x] Translated files include a comment with a link to the upstream
file
* Update package dependencies to include jest-mock-genv
* Add linker module to roblox-model
* Adding back newlines
* Spruce up lockfile
* Fix require paths
* APT-2003 Disallow require by string for now (#414)
## Problem
In future editions of Luau, require-by-string will be enabled, allowing
users to pass in string paths to `require()` which are resolved
internally to a ModuleScript instance.
## Solution
Disable this feature in Jest, because we do not yet have functionality
to match this. Throws a useful error instead.
## Testing
Unit tests.
## Checklist
- [x] All deviations are notated in code with `-- ROBLOX deviation:
comment`
* Fix a few remaining Roblox requires
* Bump darklua version
* Specify node version 22
Latest recent node version breaks the node setup and yarn won't install
things. Switching to version 22 solves this.
* APT-1914 spyOn callable tables (#413)
## Problem
Callable tables are not compatible with the `spyOn` method.
## Solution
Allow callable tables to be injected by `spyOn`, cloning their data and
metatable while replacing the `__call` with a forwarding function to the
mock object.
## Testing
Unit tests and snapshots
## Checklist (remove if not applicable)
- [x] For new modules, has a README.md file with notes about the
translation
- [x] All deviations are notated in code with `-- ROBLOX deviation:
comment`
* APT-2175 Quantum stability for RobloxInstance (#416)
## Problem
Sometimes, `RobloxInstance.listProps` is prone to returning incorrect
property listings because of quantum UI bugs.
## Solution
Perform a "cold read" of all properties to allow any quantum UI
calculations to run, then do a "warm read" to collect all the properties
once they've settled into their proper values.
This behaviour is optional. Existing features do not utilise this "warm
read" behaviour for backwards compat.
## Testing
Unit tests and snapshots
* APT-2004 Add instance mocking classes (#418)
## Problem
Jest currently lacks the facilities to adequately mock and spy on the
behaviour of `Instance` objects, because Jest's existing methods of
spying on objects are invasive.
Additionally, it's unclear how our existing mocking tech could expand to
cover the nuances of instances well.
## Solution
Introduce new internal classes for creating and working with mock
instances:
- `InstanceProxy` implementing basic proxying and mocking support
- `DataModelMocker` to house complex mocking logic for instance <->
instance operations
The implementation of `DataModelMocker` will remain pretty barebones for
now, just acting as a simple cache for proxies, because not much
functionality is needed here for the MVP of `GetService` mocks. In the
future, if we implement a translation layer to properly sandbox
instances, this will likely need to expand to support more complex data
model operations, e.g. returning already-mocked instances when indexing
into children or `.Parent`, so that `game.Workspace.Parent == game`, for
example.
## Testing
Unit tests.
* Add jest-mock-rbx package
* Update release workflow
* Fix build
* Get tests running via `yarn test`
---------
Co-authored-by: RoFlection Bot <roflection-bot@roblox.com>
Co-authored-by: jeparlefrancais <35781636+jeparlefrancais@users.noreply.github.com>
Co-authored-by: jeparlefrancais <jeparlefrancais21@gmail.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+29-1Lines changed: 29 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,37 @@
4
4
5
5
* fix warning when multiple configuration are found ([#8](https://github.com/jsdotlua/jest-lua/pull/8))
6
6
* fix error message when no tests are found ([#7](https://github.com/jsdotlua/jest-lua/pull/7))
7
+
*
8
+
## 3.10.0 (2024-10-02)
9
+
*:sparkles: Added a fallback to use `loadstring` instead of `loadmodule` in lower privileged contexts ([#392](https://github.com/Roblox/jest-roblox-internal/pull/392))
10
+
*:sparkles: Added `redactStackTrace` option to improve stability to snapshots that contain stacktraces ([#401](https://github.com/Roblox/jest-roblox-internal/pull/401))
11
+
*:hammer_and_wrench: Add more helpful error message when requiring `JestGlobals` outside test environment ([#405](https://github.com/Roblox/jest-roblox-internal/pull/405))
12
+
*:hammer_and_wrench: Error when trying to load a nonexistant `PrettyFormat` plugin ([#407](https://github.com/Roblox/jest-roblox-internal/pull/407))
13
+
*:hammer_and_wrench: Stabilize `RobloxInstance` serialization tests ([#408](https://github.com/Roblox/jest-roblox-internal/pull/408))
14
+
15
+
## 3.9.1 (2024-08-02)
16
+
*:bug: Fix a type analysis error in `JestRuntime` ([#403](https://github.com/Roblox/jest-roblox-internal/pull/403))
17
+
18
+
## 3.9.0 (2024-08-02)
19
+
*:sparkles: Support spying on Lua globals with `spyOn` ([#397](https://github.com/Roblox/jest-roblox-internal/pull/397))
20
+
*:bug: Expose safe APIs to read and write Roblox Instance properties in the `RobloxInstance` library for `PrettyFormat` to serialize Instances safely ([#398](https://github.com/Roblox/jest-roblox-internal/pull/398))
21
+
*:hammer_and_wrench: Clean up package manifests, READMEs and documentation ([#400](https://github.com/Roblox/jest-roblox-internal/pull/400)[#402](https://github.com/Roblox/jest-roblox-internal/pull/402))
22
+
23
+
## 3.8.1 (2024-06-18)
24
+
*:bug: Fix mismatched test paths between reporter and runner ([#396](https://github.com/Roblox/jest-roblox-internal/pull/395))
*:bug: Fixed jest.mock type ([#385](https://github.com/Roblox/jest-roblox-internal/pull/385))
7
35
8
36
## 3.6.1 (2024-01-16)
9
-
* Re-release of 3.6.0 with widened promise dependency that includes older versions for maximum flexibility ([#378](https://github.com/Roblox/jest-roblox-internal/pull/378))
37
+
*:hammer_and_wrench:Re-release of 3.6.0 with widened promise dependency that includes older versions for maximum flexibility ([#378](https://github.com/Roblox/jest-roblox-internal/pull/378))
10
38
11
39
## 3.6.0 (2024-01-09)
12
40
*:hammer_and_wrench: Upgrade promise dependency, but keep constraint wide so that all future 3.x versions are valid ([#374](https://github.com/Roblox/jest-roblox-internal/pull/374))
The `Jest` packages exports `runCLI`, which is the main entrypoint to run Jest Lua tests. In your entrypoint script, import `runCLI` from the `Jest` package. A basic entrypoint script can look like the following:
8
10
@@ -49,47 +51,90 @@ import TOCInline from "@theme/TOCInline";
When this option is provided, Jest Lua will assume it is running in a CI environment. This changes the behavior when a new snapshot is encountered. Instead of the regular behavior of storing a new snapshot automatically, it will fail the test and require Jest Lua to be run with `updateSnapshot`.
Automatically clear mock calls, instances, contexts and results before every test. Equivalent to calling [`jest.clearAllMocks()`](jest-object#jestclearallmocks) before each test. This does not remove any mock implementation that may have been provided.
Automatically reset mock state before every test. Equivalent to calling [`jest.resetAllMocks()`](jest-object#jestresetallmocks) before each test. This will lead to any mocks having their fake implementations removed but does not restore their initial implementation.
95
140
@@ -98,17 +143,17 @@ Automatically reset mock state before every test. Equivalent to calling [`jest.r
98
143
Automatically restore mock state and implementation before every test. Equivalent to calling [`jest.restoreAllMocks()`](JestObjectAPI.md#jestrestoreallmocks) before each test. This will lead to any mocks having their fake implementations removed and restores their initial implementation. -->
Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like "GET /api/posts with auth", then you can use `testNamePattern = "auth"`.
114
159
@@ -119,26 +164,26 @@ The regex is matched against the full name, which is a combination of the test n
An array of regexp pattern strings that are tested against all tests paths before executing the test. Contrary to `testPathPattern`, it will only run those tests with a path that does not match with the provided regexp expressions.
Use this flag to re-record every snapshot that fails during this test run. Can be used together with a test suite pattern or with `testNamePattern` to re-record snapshots.
0 commit comments