I hope to be able to replace some ugly
it('should consist of one object pushed into flagKeys.results per challenge', function () {
return expect(generateData(challenges, options.noTextHints, options.noHintUrls, '')).to.eventually.deep.include(
{
flagKeys: {
results: [
{ id: 1, chal: 1, flag: '958c64658383140e7d08d5dee091009cc0eafc1f', type: 'static', key_type: 'static', data: null }, ...
]
}
})
})
assertions (which need to specify all the object properties that I don't even care about) with
it('should consist of one object pushed into flagKeys.results per challenge', function () {
return expect(generateData(challenges, options.noTextHints, options.noHintUrls, '')).to.eventually.containSubset(
{
flagKeys: {
results: [
{ id: 1, chal: 1, flag: '958c64658383140e7d08d5dee091009cc0eafc1f' }, ...
]
}
})
})
checks. Unfortunately that does not work, because that eventually-thing is a promise with the actual compare value nested inside. This gives me errors like:
AssertionError: expected { Object (_bitField, _fulfillmentHandler0, ...) } to contain subset { Object (flagKeys) }
+ expected - actual
{
- "_bitField": 33554432
- "_fulfillmentHandler0": [undefined]
- "_promise0": [undefined]
- "_receiver0": [undefined]
- "_rejectionHandler0": {
- "challenges": {
- "results": [...]
- }
- "flagKeys": {
- "results": [
- {
- "chal": 1
- "data": [null]
- "flag": "958c64658383140e7d08d5dee091009cc0eafc1f"
- "id": 1
- "key_type": "static"
- "type": "static"
- } ...
- ]
- }
- "hints": {
- "results": []
- }
+ "flagKeys": {
+ "results": [
+ {
+ "chal": 1
+ "data": [null]
+ "flag": "958c64658383140e7d08d5dee091009cc0eafc1f"
+ } ...
+ ]
}
}
at Proxy.<anonymous> (node_modules\chai-subset\lib\chai-subset.js:20:30)
at Proxy.methodWrapper (node_modules\chai\lib\chai\utils\addMethod.js:57:25)
at Context.<anonymous> (test\unit\generateData-spec.js:38:104)
Using to.eventually.deep.containSubset does not work either. You can find the original unit test here: https://github.com/bkimminich/juice-shop-ctf/blob/develop/test/unit/generateData-spec.js#L37-L76
Thanks in advance for your help/hints! Btw, merry 🎄 to you!
I hope to be able to replace some ugly
assertions (which need to specify all the object properties that I don't even care about) with
checks. Unfortunately that does not work, because that
eventually-thing is a promise with the actual compare value nested inside. This gives me errors like:Using
to.eventually.deep.containSubsetdoes not work either. You can find the original unit test here: https://github.com/bkimminich/juice-shop-ctf/blob/develop/test/unit/generateData-spec.js#L37-L76Thanks in advance for your help/hints! Btw, merry 🎄 to you!