Commit Graph

230 Commits

Author SHA1 Message Date
Steve Gravrock b559faec2a HtmlReporterV2: show correct progress when running a subset of specs 2025-11-27 07:24:45 -08:00
Steve Gravrock 32168be6c7 Statically expose pretty printer as jasmine.pp
Pretty printing is occasionally useful outside of the places where a
configured pretty printer is injected (matchers and asymmetric equality
testers). Users sometimes use the private basicPrettyPrinter for that.
jasmine.pp is part of the public interface and uses the current runable's
custom object formatters.
2025-11-22 09:46:45 -08:00
Steve Gravrock bdf63f2402 Remove code to support browsers that don't have MessageChannel
Jasmine hasn't actually run in any such browsers since 2.x.
2025-11-12 21:59:17 -08:00
Steve Gravrock 7b2807b321 Convert clearStack from a function to an object 2025-11-11 18:54:25 -08:00
Steve Gravrock a8431f33bd Merge branch '5.99' into 6.0 2025-11-03 17:22:11 -08:00
Steve Gravrock 4995c967ac Merge branch 'main' into 5.99 2025-11-03 17:14:24 -08:00
bonkevin 27a1257b6d fix: unavailable custom matchers on top-it 2025-10-29 13:04:10 -04:00
Steve Gravrock 020dffd504 Don't spy on getGlobal 2025-10-19 10:08:05 -07:00
Steve Gravrock 0738ba6462 Omit irrelevant properties from suiteStarted 2025-10-05 06:16:57 -07:00
Steve Gravrock 168ff0a751 Move private APIs to private namespace
Fixes #2078
2025-09-27 13:21:09 -07:00
Steve Gravrock 970cbdc69c Omit irrelevant properties from specStarted 2025-09-21 15:09:38 -07:00
Steve Gravrock 17c0567bae Don't leak errorWithStack in late async expectation failures 2025-09-21 08:38:46 -07:00
Steve Gravrock 6e0342fc8e Deep clone reporter events 2025-09-20 16:18:56 -07:00
Steve Gravrock d333ecb5b1 Removed useless passed property from ThrowUnlessFailure 2025-09-20 16:17:02 -07:00
Steve Gravrock 1e98a4b61b Removed remaining paths that pass expected and actual of expectations to reporters 2025-09-20 16:16:35 -07:00
Steve Gravrock 2c6ce35ccc Pass spec metadata to filters, not internal Spec instance 2025-09-20 10:48:43 -07:00
Steve Gravrock 6ab83e25d1 Don't expose Order instances to reporters 2025-09-20 10:48:43 -07:00
Steve Gravrock 3cbf4dc27b Deprecate access to non-public Spec properties in spec filters 2025-09-20 10:48:08 -07:00
Steve Gravrock 3d8396da0a More precisely characterize suite/spec reporting 2025-09-13 10:10:42 -07:00
kbon 7feec406d9 set the right spec property key 2025-08-25 23:12:29 -04:00
kbon f822ffea21 feat(getSpecProperty) get a user-defined property 2025-08-25 23:00:06 -04:00
Steve Gravrock 395ef85954 Optionally detect late promise rejections and don't report them as errors 2025-08-09 08:35:08 -07:00
Steve Gravrock bc2aa7be25 Start breaking up integration/EnvSpec.js 2025-07-11 07:39:39 -07:00
Steve Gravrock af04599bb5 Relaxed timeout on flaky test 2025-07-09 06:56:08 -07:00
Steve Gravrock 21db6ec0e3 Removed unnecessary errorWithStack helper 2025-06-22 12:49:26 -07:00
Steve Gravrock c1cd5c6291 Use custom object formatters in spy strategy mismatch errors 2025-06-05 05:46:29 -07:00
Steve Gravrock 5ff7e7f9a1 Updated to eslint 9
This isn't officially compatible with the oldest version of Node that
Jasmine supports, but it works. If it stops working, we can always disable
linting in CI builds on older Node versions.
2025-04-07 21:39:58 -07:00
Steve Gravrock d5e7bc9fd6 Optionally enforce uniqueness of spec and suite names
This is off by default for backwards compatibility but can be enabled
by setting the forbidDuplicateNames env config property to true.

Fixes #1633.
2024-11-10 09:54:51 -08:00
Steve Gravrock d0fe5c4712 Require curly braces around loop and conditonal bodies 2024-09-02 11:30:36 -07:00
Steve Gravrock 6941bde7e2 Revert "Deprecate the suppressLoadErrors option"
jasmine-npm still needs this to enable the default behavior of crashing
with a stack trace on load errors.

This reverts commit 99e350ac85.
2024-03-21 09:34:26 -07:00
Steve Gravrock 99e350ac85 Deprecate the suppressLoadErrors option
This was intended as a 3.0 migration aid for browser users who had
dependencies that triggered errors at load time. However, it was never
documented and never supported by jasmine-brower-runner, karma, or any
other commonly used tool for runing Jasmine in the browser. There is
no evidence of it actually being used. It is, however, starting to
show up in machine-generated "tutorials".
2024-03-04 19:35:31 -08:00
Steve Gravrock 39f9c2e1a0 Don't attach spec helpers to the env 2023-08-26 11:52:26 -07:00
Steve Gravrock e56bd3918b Added throwUnless and throwUnlessAsync
These are similar to `expect` and `expectAsync` except that they throw
exceptions rather than recording matcher failures as spec/suite failures.
They're intended to support using Jasmine matchers in testing-library's
`waitFor`, and also provide a way to integration-test custom matchers.

These funtions are not equivalent to `expect` and `expectAsync` and should
not be used in situations where you want a matcher failure to reliably fail
the spec. Whether that happens depends on the structure of the surrounding
code. In general, you should only use `throwUnless` when you expect
something (which could be your own code or library code like `waitFor`) to
catch the resulting exception.

Fixes #2003.
Fixes #1980.
2023-07-15 12:08:11 -07:00
Steve Gravrock 86eddb05b4 Merge remote-tracking branch 'origin/main' into 5.0 2023-03-04 14:06:43 -08:00
Steve Gravrock 8af5509581 Added a parallel flag to the jasmineStarted reporter event 2023-03-03 20:49:10 -08:00
Steve Gravrock 166e5f4d6c Report the ID of each suite/spec's parent
This is intended to support parallel execution, which is planned for a
future release of Jasmine. Because the execution of unrelated suites will
interleave when run in parallel, reporters will not be able to assume
that the most recent `suiteStarted` event identifies the parent of the
current suite/spec. By adding this feature now, we allow reporters to
support both parallel execution and at least some 4.x versions without
having to implement two different ways of finding the parent suite.
2023-02-25 10:24:14 -08:00
Steve Gravrock 6ad8d20694 Report the path/url of the file that the spec/suite was defined in
Fixes #1884
2023-02-15 21:39:21 -08:00
Steve Gravrock 735ce6f758 Merge remote-tracking branch 'origin/5.0' into parallel 2022-09-18 09:43:31 -07:00
Steve Gravrock 430324885b Merge branch 'main' into 5.0 2022-09-18 09:41:45 -07:00
Steve Gravrock 7c2e8ce7ca Merge branch 'main' into parallel 2022-09-17 13:26:37 -07:00
Steve Gravrock d4025999b7 Report exceptions thrown by a describe before any it calls
Previously, these were masked by the "describe with no children" error.
Now they're reported as suite level errors on an empty suite.
2022-09-17 13:24:45 -07:00
Steve Gravrock 59848ca151 Coerce the random string to a seed before sending it to reporters
This fixes an error in HTMLReporter when the configured seed is a
number rather than a string, which has been allowed since 3.8.0
2022-09-03 12:36:35 -07:00
Steve Gravrock ee524831f4 Merge branch 'main' into parallel 2022-08-27 10:30:21 -07:00
Steve Gravrock 0bfbda720d Breaking change: Env#execute no longer takes a callback
Use the returned promise instead.
2022-08-21 16:35:12 -07:00
Steve Gravrock 4fcdbd39fb Breaking change: use addEventListener rather than setting window.onerror
* Generally simplifies error handling in browsers
* Makes Jasmine's own integration tests easier to debug
* Stack traces will be provided for more global errors
* ... but less error information will be provided in some browsers if the
  error comes from a file:// URL (use `npx serve` or similar instead)
* Jasmine will no longer override existing onerror handlers in browsers
* Setting window.onerror will no longer override Jasmine's global error
  handling (use jasmine.spyOnGlobalErrors instead)
2022-08-21 16:17:18 -07:00
Steve Gravrock f934e6d816 Assume that addEventListener/removeEventListener are present in browsers
Jasmine 3.0 dropped support for the last browser that didn't support
the standard event handler methods (IE 9).
2022-08-20 10:27:44 -07:00
Steve Gravrock 79c6bbc189 clearStack optimizations
* Avoid setTimeout in Node, because we don't need the overhead there.
* Still call setTimeout in browsers to prevent the tab from being killed.
* Use queueMicrotask in Safari, because it's dramatically faster than
  MessageChannel there.
* Continue to use MessageChannel in other supported browsers becuase it's
  somewhat faster than queueMicrotask there.
* Don't use setImmediate any more because there's a faster alternative in
  all supported envs.

In jasmine-core's own test suite, this yields a roughly 50-70% speedup
in Node, ~20% in Edge, and 75-90%(!) in Safari.
2022-08-15 17:50:49 -07:00
Steve Gravrock 588283cfe5 Breaking change: support for -npm reporter handling in parallel mode
* The `boot` function exported by the core module returns the same object
  every time it's called.
* Removed node_boot.js. Use the exported `boot` function instead
* JasmineStartedInfo does not have totalSpecsDefined or order in parallel mode
* JasmineDoneInfo does not have order in parallel mode
* Added incompleteCode and numWorkers to JasmineDoneInfo
2022-08-10 18:23:38 -07:00
Steve Gravrock 6c56ebc984 Added jasmine.spyOnGlobalErrorsAsync
* Allows testing code that's expected to prodeuce global errors or
  unhandled promise rejections
* Fixes #1843
* Fixes #1453
2022-06-30 18:09:56 -07:00
Steve Gravrock 55dce7d119 Extracted runnable resource management out of Env 2022-06-11 15:28:37 -07:00