Issue To Be Solved
Checking the data emitted by an event is possible using the js testing framework but is not showcased on the docs
Suggest A Solution
Include a subsection on the Send Transactions section telling how to it and including a little example.
Message from Amit explaining how it works
when executing a transaction, the result from its promise contains an events array which should give you it.
some old code of mine which should mostly work still, except might be result[0].events instead of result.events:
result = await shallPass(await sendTransaction({
code: cadenceCode,
signers: [ accountA ],
args: [ null, 2, 1, 1, 1, (tomorrow.getTime() / 1000).toString() ],
addressMap: addressMap
}))
expect(result.events.length).toBe(2)
expect(result.events[0].type.indexOf('ZayTrader.TradeCollectionInitialized') > 0).toBe(true)
expect(result.events[1].type.indexOf('ZayTrader.TradeOfferAvailable') > 0).toBe(true)
This is how result[0].events looks like with a single event
[
{
"data": {"sequence": "0", "versionTable": {"15": {"isBackwardsCompatible": true, "major": "0", "minor": "1", "patch": "2", "preRelease": "alpha.1"}}},
"eventIndex": 0,
"transactionId": "a0f210b5f0710dac3a02071b3a5492501bb02aabdb88e132a3b41f3e576cb6c3",
"transactionIndex": 1, "type": "A.01cf0e2f2f715450.NodeVersionBeacon.NodeVersionTableUpdated"
}
]