Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge latest upstream changes #16

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ roblox.toml
.vscode/launch.json
.idea
.vscode

jest_runner_tmp
lcov.info
rbx-aged-tool.log
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,29 @@
* fix warning when multiple configuration are found ([#8](https://github.com/jsdotlua/jest-lua/pull/8))
* fix error message when no tests are found ([#7](https://github.com/jsdotlua/jest-lua/pull/7))

## 3.9.1 (2024-08-02)
* :bug: Fix a type analysis error in `JestRuntime` ([#403](https://github.com/Roblox/jest-roblox-internal/pull/403))

## 3.9.0 (2024-08-02)
* :sparkles: Support spying on Lua globals with `spyOn` ([#397](https://github.com/Roblox/jest-roblox-internal/pull/397))
* :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))
* :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))

## 3.8.1 (2024-06-18)
* :bug: Fix mismatched test paths between reporter and runner ([#396](https://github.com/Roblox/jest-roblox-internal/pull/395))

## 3.8.0 (2024-05-20)
* :sparkles: Mock task.wait ([#388](https://github.com/Roblox/jest-roblox-internal/pull/373))

## 3.7.0 (2024-04-10)
* :sparkles: Resolve DOM paths to FS paths if possible in `JestRunner` ([#373](https://github.com/Roblox/jest-roblox-internal/pull/373))

## 3.6.2 (2024-03-21)
* :sparkles: Added jest.spyOn ([#382](https://github.com/Roblox/jest-roblox-internal/pull/382))
* :bug: Fixed jest.mock type ([#385](https://github.com/Roblox/jest-roblox-internal/pull/385))

## 3.6.1 (2024-01-16)
* 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))
* :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))

## 3.6.0 (2024-01-09)
* :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))
Expand Down
6 changes: 6 additions & 0 deletions bin/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ robloxdev-cli run --load.model jest.project.json \
EnableSignalBehavior=true DebugForceDeferredSignalBehavior=true MaxDeferReentrancyDepth=15 \
--lua.globals=UPDATESNAPSHOT=false --lua.globals=CI=false --load.asRobloxScript --fs.readwrite="$(pwd)"

echo "Running low privilege tests"
robloxdev-cli run --load.model jest.project.json \
--run bin/spec.lua --testService.errorExitCode=1 \
--fastFlags.overrides EnableLoadModule=false --load.asRobloxScript

# Uncomment this to update snapshots
# 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)"
40 changes: 21 additions & 19 deletions docs/docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
id: cli
title: runCLI Options
---
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli)

![Deviation](/img/deviation.svg)

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:

Expand Down Expand Up @@ -49,47 +51,47 @@ import TOCInline from "@theme/TOCInline";
## Reference

### `ci` \[boolean]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--ci) ![Aligned](/img/aligned.svg)

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

### `clearMocks` \[boolean]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--clearmocks) ![Aligned](/img/aligned.svg)

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.

### `debug` \[boolean]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--debug) ![Aligned](/img/aligned.svg)

Print debugging info about your Jest config.

### `expand` \[boolean]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--expand) ![Aligned](/img/aligned.svg)

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

### `json` \[boolean]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--json) ![Aligned](/img/aligned.svg)

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

### `listTests` \[boolean]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--listtests) ![Aligned](/img/aligned.svg)

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

### `noStackTrace` \[boolean]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--nostacktrace) ![Aligned](/img/aligned.svg)

Disables stack trace in test results output.

### `passWithNoTests` \[boolean]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--passwithnotests) ![Aligned](/img/aligned.svg)

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

### `resetMocks` \[boolean]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--resetmocks) ![Aligned](/img/aligned.svg)

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.

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

### `showConfig` \[boolean]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--showconfig) ![Aligned](/img/aligned.svg)

Print your Jest config and then exits.

### `testMatch` \[array&lt;string&gt;]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--testmatch-glob1--globn) ![API Change](/img/apichange.svg)

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

### `testNamePattern` \[regex]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--testnamepatternregex) ![Aligned](/img/aligned.svg)

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

Expand All @@ -119,26 +121,26 @@ The regex is matched against the full name, which is a combination of the test n
:::

### `testPathIgnorePatterns` \[array&lt;regex&gt;]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--testpathignorepatternsregexarray) ![API Change](/img/apichange.svg)

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.

### `testPathPattern` \[regex]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--testpathpatternregex) ![Aligned](/img/aligned.svg)

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

### `testTimeout` \[number>]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--testtimeoutnumber) ![Aligned](/img/aligned.svg)

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

### `updateSnapshot` \[boolean]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--updatesnapshot) ![Aligned](/img/aligned.svg)

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.

### `verbose` \[boolean]
<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'/>
[![Jest](/img/jestjs.svg)](https://jest-archive-august-2023.netlify.app/docs/27.x/cli#--verbose) ![Aligned](/img/aligned.svg)

Display individual test results with the test suite hierarchy.
Display individual test results with the test suite hierarchy.
Loading
Loading