|
| 1 | +import { wrapTest } from '@agoric/ses-ava'; |
| 2 | +import '@agoric/install-ses'; |
| 3 | +import rawTest from 'ava'; |
| 4 | +// import { E } from './get-hp'; |
| 5 | + |
| 6 | +// This file is a variation of the `test-ses-ava-reject` from the |
| 7 | +// `@agoric/ses-ava` package. The difference is that this test |
| 8 | +// uses `E.when` rather than `then` to demonstrate deep stacks. |
| 9 | + |
| 10 | +const test = wrapTest(rawTest); |
| 11 | + |
| 12 | +test('ses-ava reject console output', t => { |
| 13 | + t.assert(true); |
| 14 | + // Uncomment this to see something like the text in the extended comment below |
| 15 | + |
| 16 | + /* |
| 17 | + return E.when(Promise.resolve(null), v1 => |
| 18 | + E.when(v1, v2 => |
| 19 | + E.when(v2, _ => { |
| 20 | + assert.typeof(88, 'string', assert.details`msg ${'NOTICE ME'}`); |
| 21 | + }), |
| 22 | + ), |
| 23 | + ); |
| 24 | + */ |
| 25 | +}); |
| 26 | + |
| 27 | +/* |
| 28 | +Uncommenting the test code above should produce something like the following. |
| 29 | +Some of this output still comes from ava. The stack-like display comes from |
| 30 | +the SES `console`, which shows the detailed error message including the |
| 31 | +redacted `'NOTICE ME'` that ava has no access to. |
| 32 | +``` |
| 33 | +REJECTED from ava test: (TypeError#1) |
| 34 | +TypeError#1: msg NOTICE ME |
| 35 | + at packages/eventual-send/test/test-ses-ava-reject-deep-stacks.js:29:22 |
| 36 | +
|
| 37 | +TypeError#1 ERROR_NOTE: Thrown from: (Error#2) : 3 . 0 |
| 38 | +TypeError#1 ERROR_NOTE: Rejection from: (Error#3) : 2 . 1 |
| 39 | +TypeError#1 ERROR_NOTE: Rejection from: (Error#4) : 1 . 1 |
| 40 | +Nested 3 errors under TypeError#1 |
| 41 | + Error#2: Event: 2.1 |
| 42 | + at packages/eventual-send/test/test-ses-ava-reject-deep-stacks.js:28:9 |
| 43 | +
|
| 44 | + Error#2 ERROR_NOTE: Caused by: (Error#3) |
| 45 | + Nested error under Error#2 |
| 46 | + Error#3: Event: 1.1 |
| 47 | + at packages/eventual-send/test/test-ses-ava-reject-deep-stacks.js:27:7 |
| 48 | +
|
| 49 | + Error#3 ERROR_NOTE: Caused by: (Error#4) |
| 50 | + Nested error under Error#3 |
| 51 | + Error#4: Event: 0.1 |
| 52 | + at packages/eventual-send/test/test-ses-ava-reject-deep-stacks.js:26:12 |
| 53 | + at async Promise.all (index 0) |
| 54 | +
|
| 55 | + ses-ava reject console output |
| 56 | +
|
| 57 | + Rejected promise returned by test. Reason: |
| 58 | +
|
| 59 | + TypeError { |
| 60 | + message: 'msg (a string)', |
| 61 | + } |
| 62 | +
|
| 63 | + › packages/eventual-send/test/test-ses-ava-reject-deep-stacks.js:29:22 |
| 64 | +
|
| 65 | + ─ |
| 66 | +
|
| 67 | + 1 test failed |
| 68 | +``` |
| 69 | +*/ |
0 commit comments