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
Copy file name to clipboardExpand all lines: README.md
+19-2Lines changed: 19 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,10 @@ Both methods are called with a single `event` argument, it will have the followi
85
85
86
86
-`event.originalMessage` - The actual value the user provided for optional `message` parameter. This will be `undefined` if the user did not provide a value, even if the underlying assertion provides a default message.
87
87
88
+
-`event.defaultMessage` - If you use objects instead of strings to specify patterns (see below), the `defaultMessage` metadata will be copied directly on the event object.
89
+
90
+
-`event.matcherSpec` - This contains the complete parsed matcher spec as supplied, as well as any additional metadata you may have supplied (see patterns section below for details on how to supply additional metadata).
91
+
88
92
-`event.args` - An array of the actual arguments passed to the assertion.
89
93
90
94
-`event.assertionThrew` - Whether or not the underlying assertion threw an error. This will always be `true` in an `onError` callback, and always `false` in an `onSuccess` callback.
@@ -118,7 +122,7 @@ TBD
118
122
119
123
| type | default value |
120
124
|:--------------------|:--------------------|
121
-
|`Array` of `string`| objects shown below |
125
+
|`Array` of `string`or `objects`| objects shown below |
Target patterns for power assert feature instrumentation.
139
142
140
143
Pattern detection is done by [call-signature](https://github.com/jamestalmage/call-signature). Any arguments enclosed in bracket (for example, `[message]`) means optional parameters. Without bracket means mandatory parameters.
141
144
145
+
Instead of a string, you may alternatively specify an object with a `pattern` property, and any other arbitrary data.
146
+
Currently only `defaultMessage` is formally recommended, but you can attach any data here and it will be passed to the `onSuccess` and `onError` handlers.
147
+
148
+
```javascript
149
+
[
150
+
{
151
+
pattern:'assert.fail([message])',
152
+
defaultMessage:'assert.fail() was called!!'
153
+
},
154
+
...
155
+
]
156
+
```
157
+
142
158
#### options.wrapOnlyPatterns
143
159
144
160
| type | default value |
@@ -147,6 +163,7 @@ Pattern detection is done by [call-signature](https://github.com/jamestalmage/ca
147
163
148
164
Methods matching these patterns will not be instrumented by the code transform, but they will be wrapped at runtime and trigger events in the `onSuccess` and `onError` callbacks. Note that "wrap only" events will never have a `powerAssertContext` property.
149
165
166
+
Similar to the `options.patterns`, you may supply objects with a `pattern` member, and the additional metadata will be passed to the assertion listeners.
0 commit comments