Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib/test: Add diagnostic Test.context for Mochawesome
This is, as far as I know, Mochawesome-specific, which makes it a bit of a hack. The Mochawesome side of this is adamgruber/mochawesome@65e90621 (implement addContext method for adding report context to tests, 2016-12-20, adamgruber/mochawesome#106). Ideally we'd want a way to trigger this as part of requesting Mochawesome as the reporter, but the addition seems harmless enough so I'm just including it every time. In the diag.source case, we might want to expose diagnostics besides .fn. But we surely don't want to expose the test source via both .fn and .context. For this commit, I've left the diag.source case alone, but in future work we might want something closer to : if (result.diag) { var context = Object.assign({}, result.diag) if (context.source) { var source = context.source delete context.source this.fn = { toString: function () { return 'function(){' + source + '\n}' } } } if (Object.keys(context).length) { this.context = { title: 'diagnostic', value: context, } } } I haven't done that here, because Object.assign is not supported on Internet Exporer, Android webview, or Opera for Android [1], despite being part of ECMAScript 2015 [2]. Object.keys seems to be supported everywhere [3]. We may only care about Node for this package, but I'm being conservative for this commit. [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Browser_compatibility [2]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Specifications [3]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys#Browser_compatibility
- Loading branch information