-
Notifications
You must be signed in to change notification settings - Fork 139
Description
Context: Using Karma, Jasmine, and Webpack.
When Karma runs against Chrome, td.verify() reports accurately in all synchronous cases, e.g.
describe('myMethod', function () {
it('calls my other service', function () {
myMethod()
td.verify(myOtherService.method(123));
});
});
If myOtherService.method is called with argument 122, the debugger in the browser and the karma server running in the terminal both report the error as noted in the docs.
However, when Karma runs against Chrome, td.verify() does not report asynchronous cases in the karma server, e.g.
describe('myMethod', function () {
it('calls my other service', function () {
myMethod().then(function () {
td.verify(myOtherService.method(123));
});
});
});
If myOtherService.method is called with argument 122 the debugger in the browser will report the error as noted in the docs. The terminal, however, will not report any errors. This is not ideal, but it's ultimately fine as long as I can check the browser.
The issue is when I run Karma against PhantomJS. The promise api didn't initially work, so I added the babel polyfill for es6 promises (reference: https://stackoverflow.com/a/31166888/1922806). This didn't work right away, but adding td.config({ promiseConstructor: Promise }) got the tests running. This presents a similar case to the one above (except without the browser debugger as backup). Synchronous td.verify() works great and reports in the terminal.
Asynchronous td.verify() does not fail the test, and does not report accurately. Instead it throws an error like this:
Error { line: 8988, sourceURL: 'http://localhost:9876/base/node_modules/testdouble/dist/testdouble.js?294aaf185ca326f12f3631a16e3fbc319c20e47d', stack: and then a stack trace which bounces between test double, the spec file, and the polyfill }
I think, since the reporting to the karma server doesn't seem to be working when run against PhantomJS or Chrome, that the issue might not be with the Promise constructor but with the actual reporting, but I wanted to open this issue to see if it might be a result of testdouble.