Skip to content
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

TypeError: Cannot read property 'results' of undefined #11

Closed
shenqihui opened this issue Jun 29, 2015 · 1 comment
Closed

TypeError: Cannot read property 'results' of undefined #11

shenqihui opened this issue Jun 29, 2015 · 1 comment

Comments

@shenqihui
Copy link

Hello, i find some problem when test file has some error.
And this will break karma test task.

PhantomJS 1.9.8 (Linux 0.0.0) ERROR
  ReferenceError: Can't find variable: alter
  at /home/vagrant/github/karma_test/src/hello_src.js:12

undefined
ERROR [karma]: [TypeError: Cannot read property 'results' of undefined]
TypeError: Cannot read property 'results' of undefined
    at onBrowserComplete (/home/vagrant/github/karma_test/node_modules/karma-htmlfile-reporter/index.js:90:10)
    at null.<anonymous> (/home/vagrant/github/karma_test/node_modules/karma/lib/events.js:14:22)
    at emit (events.js:117:20)
    at onComplete (/home/vagrant/github/karma_test/node_modules/karma/lib/browser.js:142:13)
    at Socket.<anonymous> (/home/vagrant/github/karma_test/node_modules/karma/lib/events.js:14:22)
    at Socket.emit [as $emit] (events.js:117:20)
    at SocketNamespace.handlePacket (/home/vagrant/github/karma_test/node_modules/karma/node_modules/socket.io/lib/namespace.js:335:22)
    at Manager.onClientMessage (/home/vagrant/github/karma_test/node_modules/karma/node_modules/socket.io/lib/manager.js:488:38)
    at WebSocket.Transport.onMessage (/home/vagrant/github/karma_test/node_modules/karma/node_modules/socket.io/lib/transport.js:387:20)
    at Parser.<anonymous> (/home/vagrant/github/karma_test/node_modules/karma/node_modules/socket.io/lib/transports/websocket/default.js:36:10)

And i find the problem.
link this https://github.com/matthias-schuetz/karma-htmlfile-reporter/blob/master/index.js#L87

this.onBrowserComplete = function(browser) {
    var suite = suites[browser.id];
    var result = browser.lastResult;

    suite['results'].txt(result.total + ' tests / ');
    suite['results'].txt((result.disconnected || result.error ? 1 : 0) + ' errors / ');
    suite['results'].txt(result.failed + ' failures / ');
    suite['results'].txt(result.skipped + ' skipped / ');
    suite['results'].txt('runtime: ' + ((result.netTime || 0) / 1000) + 's');

    if (allMessages.length > 0) {
        suite.ele('tr', {class:'system-out'}).ele('td', {colspan:'3'}).raw('<strong>System output:</strong><br />' + allMessages.join('<br />'));
    }
  };

here suite is undefined.
And i think we should test it before use just using if statement.

@matthias-schuetz
Copy link
Owner

Sorry for the late response, I've tested and added your code changes, it works!
Thanks for your attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants