Skip to content

Commit f7456ea

Browse files
vockselRoFlection Botjeparlefrancais
authored
Merge latest upstream changes (#16)
* 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>
1 parent cfd476e commit f7456ea

File tree

150 files changed

+4018
-1461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+4018
-1461
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
- uses: actions/setup-node@v3
2020
with:
21-
node-version: "latest"
21+
node-version: 22
2222
cache: "yarn"
2323
cache-dependency-path: "yarn.lock"
2424

.github/workflows/release.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
- uses: actions/setup-node@v3
3131
with:
32-
node-version: "latest"
32+
node-version: 22
3333
cache: "yarn"
3434
cache-dependency-path: "yarn.lock"
3535

@@ -66,7 +66,7 @@ jobs:
6666

6767
- uses: actions/setup-node@v3
6868
with:
69-
node-version: "latest"
69+
node-version: 22
7070
cache: "yarn"
7171
cache-dependency-path: "yarn.lock"
7272

@@ -109,6 +109,12 @@ jobs:
109109
- name: Publish jest-mock to wally
110110
run: wally publish --project-path build/wally/jest-mock
111111

112+
- name: Publish jest-mock-genv to wally
113+
run: wally publish --project-path build/wally/jest-mock-genv
114+
115+
- name: Publish jest-mock-rbx to wally
116+
run: wally publish --project-path build/wally/jest-mock-rbx
117+
112118
- name: Publish jest-roblox-shared to wally
113119
run: wally publish --project-path build/wally/jest-roblox-shared
114120

@@ -178,7 +184,6 @@ jobs:
178184
- name: Publish jest to wally
179185
run: wally publish --project-path build/wally/jest
180186

181-
182187
create-release:
183188
needs: publish-package
184189

@@ -239,7 +244,7 @@ jobs:
239244

240245
- uses: actions/setup-node@v3
241246
with:
242-
node-version: "latest"
247+
node-version: 22
243248
cache: "yarn"
244249
cache-dependency-path: "yarn.lock"
245250

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- uses: actions/setup-node@v3
2727
with:
28-
node-version: "latest"
28+
node-version: 22
2929
cache: "yarn"
3030
cache-dependency-path: "yarn.lock"
3131

@@ -60,7 +60,7 @@ jobs:
6060

6161
# - uses: actions/setup-node@v3
6262
# with:
63-
# node-version: "latest"
63+
# node-version: 22
6464
# cache: "yarn"
6565
# cache-dependency-path: "yarn.lock"
6666

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ roblox.toml
4040
.vscode/launch.json
4141
.idea
4242
.vscode
43+
44+
jest_runner_tmp
45+
lcov.info
46+
rbx-aged-tool.log

CHANGELOG.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,37 @@
44

55
* fix warning when multiple configuration are found ([#8](https://github.com/jsdotlua/jest-lua/pull/8))
66
* 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))
25+
26+
## 3.8.0 (2024-05-20)
27+
* :sparkles: Mock task.wait ([#388](https://github.com/Roblox/jest-roblox-internal/pull/373))
28+
29+
## 3.7.0 (2024-04-10)
30+
* :sparkles: Resolve DOM paths to FS paths if possible in `JestRunner` ([#373](https://github.com/Roblox/jest-roblox-internal/pull/373))
31+
32+
## 3.6.2 (2024-03-21)
33+
* :sparkles: Added jest.spyOn ([#382](https://github.com/Roblox/jest-roblox-internal/pull/382))
34+
* :bug: Fixed jest.mock type ([#385](https://github.com/Roblox/jest-roblox-internal/pull/385))
735

836
## 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))
1038

1139
## 3.6.0 (2024-01-09)
1240
* :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))

bin/ci.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,13 @@ robloxdev-cli run --load.model jest.project.json \
1414
EnableSignalBehavior=true DebugForceDeferredSignalBehavior=true MaxDeferReentrancyDepth=15 \
1515
--lua.globals=UPDATESNAPSHOT=false --lua.globals=CI=false --load.asRobloxScript --fs.readwrite="$(pwd)"
1616

17-
# robloxdev-cli run --load.model jest.project.json --run bin/spec.lua --testService.errorExitCode=1 --fastFlags.allOnLuau --fastFlags.overrides EnableLoadModule=true DebugDisableOptimizedBytecode=true --lua.globals=UPDATESNAPSHOT=true --lua.globals=CI=true --load.asRobloxScript --fs.readwrite="$(pwd)"
17+
# echo "Running low privilege tests"
18+
robloxdev-cli run --load.model jest.project.json \
19+
--run bin/spec.lua --testService.errorExitCode=1 \
20+
--fastFlags.overrides EnableLoadModule=false --load.asRobloxScript
21+
22+
# Uncomment this to update snapshots
23+
# robloxdev-cli run --load.model jest.project.json \
24+
# --run bin/spec.lua --testService.errorExitCode=1 \
25+
# --fastFlags.allOnLuau --fastFlags.overrides EnableLoadModule=true DebugDisableOptimizedBytecode=true \
26+
# --lua.globals=UPDATESNAPSHOT=true --lua.globals=CI=true --load.asRobloxScript --fs.readwrite="$(pwd)"

docs/docs/CLI.md

Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
id: cli
33
title: runCLI Options
44
---
5-
<p><a href='https://jestjs.io/docs/27.x/cli' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a></p> <img alt='Deviation' src='img/deviation.svg'/>
5+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli)
6+
7+
![Deviation](/img/deviation.svg)
68

79
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:
810

@@ -49,47 +51,90 @@ import TOCInline from "@theme/TOCInline";
4951
## Reference
5052

5153
### `ci` \[boolean]
52-
<a href='https://jestjs.io/docs/27.x/cli#--ci' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
54+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--ci) ![Aligned](/img/aligned.svg)
5355

5456
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`.
5557

5658
### `clearMocks` \[boolean]
57-
<a href='https://jestjs.io/docs/27.x/cli#--clearmocks' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
59+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--clearmocks) ![Aligned](/img/aligned.svg)
5860

5961
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.
6062

6163
### `debug` \[boolean]
62-
<a href='https://jestjs.io/docs/27.x/cli#--debug' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
64+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--debug) ![Aligned](/img/aligned.svg)
6365

6466
Print debugging info about your Jest config.
6567

6668
### `expand` \[boolean]
67-
<a href='https://jestjs.io/docs/27.x/cli#--expand' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
69+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--expand) ![Aligned](/img/aligned.svg)
6870

6971
Use this flag to show full diffs and errors instead of a patch.
7072

7173
### `json` \[boolean]
72-
<a href='https://jestjs.io/docs/27.x/cli#--json' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
74+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--json) ![Aligned](/img/aligned.svg)
7375

7476
Prints the test results in JSON. This mode will send all other test output and user messages to stderr.
7577

7678
### `listTests` \[boolean]
77-
<a href='https://jestjs.io/docs/27.x/cli#--listtests' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
79+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--listtests) ![Aligned](/img/aligned.svg)
7880

7981
Lists all test files that Jest Lua will run given the arguments, and exits.
8082

8183
### `noStackTrace` \[boolean]
82-
<a href='https://jestjs.io/docs/27.x/cli#--nostacktrace' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
84+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--nostacktrace) ![Aligned](/img/aligned.svg)
8385

8486
Disables stack trace in test results output.
8587

88+
### `oldFunctionSpying` \[boolean]
89+
![Roblox only](/img/roblox-only.svg)
90+
91+
Changes how [`jest.spyOn()`](jest-object#jestspyonobject-methodname) overwrites
92+
methods in the spied object, making it behave like older versions of Jest.
93+
94+
* When `oldFunctionSpying = true`, it will overwrite the spied method with a
95+
*mock object*. (old behaviour)
96+
* When `oldFunctionSpying = false`, it will overwrite the spied method with a
97+
*regular Lua function*. (new behaviour)
98+
99+
Regardless of the value of `oldFunctionSpying`, the `spyOn()` function will
100+
always return a mock object.
101+
102+
```lua
103+
-- when `oldFunctionSpying = false` (old behaviour)
104+
105+
local guineaPig = {
106+
foo = function() end
107+
}
108+
109+
local mockObj = jest.spyOn(guineaPig, "foo")
110+
mockObj.mockReturnValue(25)
111+
112+
print(typeof(guineaPig.foo)) --> table
113+
print(typeof(mockObj)) --> table
114+
print(guineaPig.foo == mockObj) --> true
115+
```
116+
117+
```lua
118+
-- when `oldFunctionSpying = true` (new behaviour)
119+
120+
local guineaPig = {
121+
foo = function() end
122+
}
123+
124+
local mockObj = jest.spyOn(guineaPig, "foo")
125+
126+
print(typeof(guineaPig.foo)) --> function
127+
print(typeof(mockObj)) --> table
128+
print(guineaPig.foo == mockObj) --> false
129+
```
130+
86131
### `passWithNoTests` \[boolean]
87-
<a href='https://jestjs.io/docs/27.x/cli#--passwithnotests' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
132+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--passwithnotests) ![Aligned](/img/aligned.svg)
88133

89134
Allows the test suite to pass when no files are found.
90135

91136
### `resetMocks` \[boolean]
92-
<a href='https://jestjs.io/docs/27.x/cli#--resetmocks' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
137+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--resetmocks) ![Aligned](/img/aligned.svg)
93138

94139
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.
95140

@@ -98,17 +143,17 @@ Automatically reset mock state before every test. Equivalent to calling [`jest.r
98143
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. -->
99144

100145
### `showConfig` \[boolean]
101-
<a href='https://jestjs.io/docs/27.x/cli#--showconfig' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
146+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--showconfig) ![Aligned](/img/aligned.svg)
102147

103148
Print your Jest config and then exits.
104149

105150
### `testMatch` \[array&lt;string&gt;]
106-
<a href='https://jestjs.io/docs/27.x/cli#--testmatch-glob1--globn' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='API change' src='img/apichange.svg'/>
151+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--testmatch-glob1--globn) ![API Change](/img/apichange.svg)
107152

108153
The glob patterns Jest uses to detect test files. Please refer to the [`testMatch` configuration](configuration#testmatch-arraystring) for details.
109154

110155
### `testNamePattern` \[regex]
111-
<a href='https://jestjs.io/docs/27.x/cli#--testnamepatternregex' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
156+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--testnamepatternregex) ![Aligned](/img/aligned.svg)
112157

113158
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"`.
114159

@@ -119,26 +164,26 @@ The regex is matched against the full name, which is a combination of the test n
119164
:::
120165

121166
### `testPathIgnorePatterns` \[array&lt;regex&gt;]
122-
<a href='https://jestjs.io/docs/27.x/cli#--testpathignorepatternsregexarray' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='API change' src='img/apichange.svg'/>
167+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--testpathignorepatternsregexarray) ![API Change](/img/apichange.svg)
123168

124169
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.
125170

126171
### `testPathPattern` \[regex]
127-
<a href='https://jestjs.io/docs/27.x/cli#--testpathpatternregex' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
172+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--testpathpatternregex) ![Aligned](/img/aligned.svg)
128173

129174
A regexp pattern string that is matched against all tests paths before executing the test.
130175

131176
### `testTimeout` \[number>]
132-
<a href='https://jestjs.io/docs/27.x/cli#--testtimeoutnumber' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
177+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--testtimeoutnumber) ![Aligned](/img/aligned.svg)
133178

134179
Default timeout of a test in milliseconds. Default value: 5000.
135180

136181
### `updateSnapshot` \[boolean]
137-
<a href='https://jestjs.io/docs/27.x/cli#--updatesnapshot' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
182+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--updatesnapshot) ![Aligned](/img/aligned.svg)
138183

139184
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.
140185

141186
### `verbose` \[boolean]
142-
<a href='https://jestjs.io/docs/27.x/cli#--verbose' target="_blank"><img alt='Jest' src='img/jestjs.svg'/></a> <img alt='Aligned' src='img/aligned.svg'/>
187+
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--verbose) ![Aligned](/img/aligned.svg)
143188

144-
Display individual test results with the test suite hierarchy.
189+
Display individual test results with the test suite hierarchy.

0 commit comments

Comments
 (0)