-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using 'window.__karma__.info()` API to send arbitrary objects to the server does not work #2192
Using 'window.__karma__.info()` API to send arbitrary objects to the server does not work #2192
Comments
Any one have an idea? |
@dignifiedquire Are you aware of any karma reporter plugins which are using the window.karma.info API? |
@devanshah1 I know of nothing that actually uses this api I'm afraid |
@dignifiedquire Do you know of any other way to send arbitrary objects to the server from the client? |
@dignifiedquire I started taking a look at this issues and had a quick question regarding it, in terms of how it should be used? When you call the window.karma.info() API would it be able to be picked up by any reporter that is registered. And Also would the API only work if where you are calling it from is part of a karma start function. |
@dignifiedquire would you be able to provide some context in terms of how the actual socket call is made, I see that the emmiter is from the karma.js file, but how is this actually emmited for reporter to pick up. By the looks of it is through socket.io, like just wanted to figure out if the following from https://github.com/karma-runner/karma/blob/master/client/karma.js is actually called or not: this.info = function (info) {
// TODO(vojta): introduce special API for this
if (!startEmitted && util.isDefined(info.total)) {
socket.emit('start', info)
startEmitted = true
} else {
socket.emit('info', info)
}
} |
It is called and should be working afaict. But I have never tried to use it so there might be issues with it. |
@dignifiedquire If I was to use socket.io on client side and dispatch an custom event and then have the reporter listening on this event, would this work? |
@dignifiedquire any idea on an ETA, in terms of if this is in fact an issues in Karma or something I am doing that is wrong to use the actual API? |
I am also seeing the same issue with this API, is there a ETA on this? |
@dignifiedquire @wesleycho @maksimr I used the |
@dignifiedquire @wesleycho @maksimr Not sure if you have had a change to take a look at this one. |
After some investigation, I think it never worked as you want. Answers to questions:
Yes, karma itself because karma sends
As a workaround(hack), you can inject executor to your reporter and use sockets directly.
As in your example, only the event will be named as 'browser_info'. client: window.__karma__.info({foo: 'foo'}); server/backend: emitter.on('browser_info', () => {});
No, because emitter is not socket, only browser subscribed on all sockets events so you could create custom method in custom browser launcher like 'onFoo' and send event 'foo'.
No matter reporter, browser or another code. If you inject emitter and subscribe on 'browser_info' you will receive event.
I think it will be called only if browser starts to execute tests as It was done for 'browser_log'
Yes, it works
I will try add such functionality soon |
@maksimr Thanks a lot for taking a look at this. So the PR that you added I should be able to add emitter.on('browser_info', () => {}); to the reporter and then on the client side stilling having: window.__karma__.info({foo: 'foo'}); will make things work right? |
@devanshah1 yup |
@maksimr Awesome thanks a lot for this PR |
@dignifiedquire @maksimr Any idea on when this can be released? |
I will try to make a release over the weekend |
@dignifiedquire Thanks a lot |
@dignifiedquire @maksimr Thanks a lot for this, works like a charm. |
Expected behavior
Expect the info emitter to be dispatched which is set in the reporter. The reporter is expected to write to console a message. Refer to: https://groups.google.com/forum/#!topic/karma-users/ShR96TcKm6Q
Actual behavior
Nothing is written to the terminal/console.
Enviroment Details
karma --version
): Tried on "0.13.22" and "1.0.0"karma.config.js
fileRefer to: https://github.com/devanshah1/sample/blob/master/karma.conf.js
Steps to reproduce the behaviour
bash npm install
in repo folderbash npm install src
in repo foldernpm test
in repo folderThe text was updated successfully, but these errors were encountered: