Commit Graph

710 Commits

Author SHA1 Message Date
Steve Gravrock 58ef707bc6 Added jasmine.isSpy to the public interface
* Fixes #1880
2021-03-17 17:58:51 -07:00
Steve Gravrock 8d0c52e2ec Temporarily removed global error handler stack validation
This fails somewhat frequently (every 2-4 runs of Jasmine's own test
suite) on Safari. Until we get to the bottom of that, it's removed.
2021-03-14 11:46:23 -07:00
Steve Gravrock 76f34e90dc Allow custom object formatters to be added in beforeAll
Fixes #1876.
2021-03-13 13:49:30 -08:00
Steve Gravrock 46e7158c77 Removed unused util.htmlEscape 2021-03-04 12:46:23 -08:00
Steve Gravrock 1320b0614f Merge branch 'use-global-onerror' into main
* Merges #1860 from @greghuc
* Allows specs to disable Jasmine's global error handling by overwriting
  `onerror`.
2020-11-24 11:13:24 -08:00
Gregory Huczynski 905e3fc3f9 Enable custom promise error handling through overriding of global.onerror 2020-11-24 11:04:04 -08:00
Steve Gravrock 89331bb1bb Fixed comparison between URL objects
* Fixes #1866
2020-11-21 13:47:44 -08:00
Jannes Meyer 60bbe68148 Support source maps 2020-11-05 11:40:04 +01:00
DCtheTall d5d5d1965f Have properties added by createSpyObj() be enumerable. 2020-10-02 13:49:34 -04:00
Steve Gravrock d27bb8fa96 Run Prettier on all files 2020-09-29 18:05:38 -07:00
Steve Gravrock e7daa429a1 Show the name of the spec/suite that caused a deprecation 2020-09-13 12:59:25 -07:00
Steve Gravrock 51ad18cb28 Warn if a runable both takes a callback and returns a promise 2020-09-13 12:47:24 -07:00
Steve Gravrock 0b81705c11 Detect global error handler stack corruption 2020-09-02 14:43:17 -07:00
Steve Gravrock 00feef8632 Fixed global error handler stack corruption in Jasmine's own tests 2020-09-02 14:01:57 -07:00
Steve Gravrock 8cb44582bc Don't overwrite MatchersUtil methods with ones that were added to Array.prototype, esp. contains
Fixes #1849.
2020-09-01 15:18:53 -07:00
Steve Gravrock 53d8073707 Allow generator functions to be passed to .and.callFake
Fixes #1848.
2020-08-29 13:15:14 -07:00
Aaron Snailwood 6277046213 fix typo in asyncMatcher toBePending comment 2020-08-20 10:07:35 -07:00
Steve Gravrock 6b9739030d Fixed future deprecations 2020-08-02 12:57:28 -07:00
Steve Gravrock 0cfeb0b9c3 Fixed link to custom object formatter tutorial 2020-07-23 16:36:56 -07:00
Steve Gravrock 70c416d5c9 Fixed jsdocs for recent additions 2020-07-10 15:41:02 -07:00
Steve Gravrock aa6cc31057 Show diffs involving root-level asymmetric equality testers
* Fixes #1831
2020-07-08 17:02:11 -07:00
Steve Gravrock 4e2f703615 Check for syntax and standard library objects that don't work in IE 2020-07-01 17:34:59 -07:00
Steve Gravrock ba2aae63be Run eslint against all files 2020-07-01 16:09:14 -07:00
Steve Gravrock b3ab9fad9d Updated toHaveBeenCalledOnceWith for new matcher interface 2020-06-26 15:14:02 -07:00
Steve Gravrock 13b967b59c Merge branch 'feat/to-have-been-called-once-with' of https://github.com/Maximaximum/jasmine into pr-merge
* Merges #1801 from @Maximaximum
* Fixes #1717
2020-06-26 15:05:04 -07:00
Terence D. Honles 3943cc2ddb allow spy throwError to throw an Object
When using the following code to simulate a node error:

  spyOn(process, 'kill').and.throwError({code: 'ESRCH'})

The object passed in will be converted to a string by the Error
constructor and result in '[object Object]' which is not very useful.
This PR changes the ``throwError`` spy strategy to only convert
strings into an Error object, but any other objects which are passed
in will be thrown as is. This means the spy strategy can never emulate
throwing a bare string ``throw 'error'``, but this would be a backward
incompatible change.
2020-06-25 18:12:00 -07:00
johnjbarton 0cb304131f fix(env): expose setSpec/SuiteProperty on interface 2020-05-26 14:50:01 -07:00
Steve Gravrock 8a731e17a7 Improved jsdocs for user-specified spec/suite properties 2020-05-05 17:58:16 -07:00
Steve Gravrock 7416c176a7 Merge branch 'properties' of https://github.com/johnjbarton/jasmine
* Merges #1763 from @johnjbarton
2020-05-05 17:45:43 -07:00
Maksym Kobieliev 0f6ebaa784 Merge branch 'master' into feat/to-have-been-called-once-with 2020-04-14 22:08:13 +03:00
johnjbarton f90d9943fe feat(env): setSpecProperty/setSuiteProperty(key, value) to attach data to tests
Use setSpecProperty to attach key/value pairs to spec results that can be
picked up in specialized jasmine reporters.  Example use-cases
include:
  * Tagging specs with URLs or string-tokens referencing test-plan docs.
  * Recording performance information for blocks of JS.
Similarly setSuiteProperty attaches key/value pairs to suite results
2020-04-14 11:27:14 -07:00
Steve Gravrock 8991b1bba3 Fixed toHaveSize matcher on IE 10 & 11 2020-04-12 21:22:14 -07:00
DCtheTall 76a99aef86 add missing trailing newline 2020-04-09 15:19:47 -04:00
DCtheTall 6b213a958d Add expectAsync().toBePending() 2020-04-09 15:13:33 -04:00
Maksym Kobieliev bcc28d7063 Output a diff if there was only one call, but with wrong parameters 2020-04-02 21:31:17 +03:00
Gregg Van Hove 79d55216fc Use internal type checks instead of instanceof to support browsers that don't include the types 2020-03-18 08:57:44 -07:00
Gregg Van Hove ec3ebcb7bb Clean up toHaveSize 2020-03-18 08:13:21 -07:00
Francois Wauquier c521b4d47c toHaveSize 2020-03-18 08:13:10 -07:00
Maksym Kobieliev e13fd13529 Add a toHaveBeenCalledOnceWith matcher 2020-03-13 20:41:24 +02:00
Steve Gravrock 93ad31e0af Correctly report spec and suite duration
Previously, suite duration was always reported as 0 and spec duration
was always reported as null. Suites always used a no-op timer, and
specs set their result.duration after the result had already been sent
to reporters.

Fixes #1676.
2020-02-22 16:53:36 -08:00
Steve Gravrock a6a9550d1e Fixed 'since' versions for MatchersUtil 2020-02-13 10:52:54 -08:00
Steve Gravrock 258d55469e Merge branch 'cof-merge-candidate'
* Simplifies the matcher interface
* Adds support for custom object formatters
2020-02-12 15:16:28 -08:00
Steve Gravrock 5096d9af4e Don't construct unnecessarily asymmetricEqualityTesterArgCompatShims
This speeds up MatchersUtil#equals by about 6-7x.
2020-02-12 14:23:03 -08:00
Steve Gravrock 3be797c8d8 Fixed diffs involving jasmine.objectContaining 2020-02-12 14:22:51 -08:00
Steve Gravrock c2ada1af95 Merge branch 'custom-object-formatters' into cof-merge-candidate 2020-02-11 13:51:17 -08:00
Pivotal ea3dd9dffc Refer to MatchersUtil instances as matchersUtil, not util 2020-02-10 17:26:05 -08:00
Steve Gravrock d41139fea2 Added jsdocs for MatchersUtil 2020-02-10 17:26:05 -08:00
Steve Gravrock 873d1c2945 Use custom object formatters for any part of a diff, not just leaf nodes 2020-02-10 17:26:00 -08:00
Steve Gravrock 25816a6e77 Added support for custom object formatters
Custom object formatters allow users to customize how an object is
stringified in matcher failure messages. This can already be done by
adding a `jasmineToString` method to the objects in question. But
it's not always desirable or possible to do that, particularly when
objects of a given "type" do not inherit from a specific prototype.
For instance, suppose a web service returns a list of foos that are
deserialized from JSON, e.g.:

   { fooId: 42, /* more properties */ }

The only way to define `jasmineToString` on those is by writing code to
add it to each instance at runtime. But a custom object formatter can
recognize that the object it's looking at is a foo and format it
accordingly:

   jasmine.addCustomObjectFormatter(function(obj) {
      if (typeof obj.fooId !== 'number') {
            return undefined;
        }

        return '[Foo with ID ' + obj.fooId + ']';
    });

Unlike `jasmineToString`, custom object formatters are scoped to a
particular spec or suite and don't require any changes to the code
under test.
2020-02-10 17:26:00 -08:00
Steve Gravrock 1f23f1e4d2 Inject a per-runable pretty printer into MatchersUtil
This will allow us to add support for custom object formatters, which
will be a per-runable resource like custom matchers, by injecting them
into the pretty-printer.
2020-02-10 17:26:00 -08:00