Skip to content

Commit

Permalink
Revert "Implement consoleRedirect: true"
Browse files Browse the repository at this point in the history
This reverts commit 64ca79d. It turns out that this wasn't really
necessary after all, as Karma is supposed to redirect this by itself. I
was however somewhat deceived by it not redirecting console.log. This
was a unintentional breaking change of karma-1.5.0 [1].

The workaround for the issue of missing log statements is to override
the default `level` of `browserConsoleLogOptions`, as shown below.

  // karma.conf.js
  module.exports = function(config) {
    config.set({
      browsers: ['jsdom'],

      browserConsoleLogOptions: {
        level: 'log'
      }
    });
  };

[1] karma-runner/karma#2582
  • Loading branch information
badeball committed May 1, 2017
1 parent 9d7b0e8 commit 1ae32f5
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 65 deletions.
11 changes: 0 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ var jsdomBrowser = function (baseBrowserDecorator, config) {
this.name = "jsdom";

this._start = function (url) {
var virtualConsole = null;

if (jsdom.JSDOM) { // Indicate jsdom >= 10.0.0 and a new API
if (config.redirectConsole) {
virtualConsole = new jsdom.VirtualConsole().sendTo(console);
}

var jsdomOptions = {
resources: "usable",
runScripts: "dangerously",
Expand All @@ -35,13 +29,8 @@ var jsdomBrowser = function (baseBrowserDecorator, config) {

jsdom.JSDOM.fromURL(url, jsdomOptions);
} else {
if (config.redirectConsole) {
virtualConsole = jsdom.createVirtualConsole().sendTo(console);
}

var jsdomOptions = {
url: url,
virtualConsole: virtualConsole,
features : {
FetchExternalResources: ["script", "iframe"],
ProcessExternalResources: ["script"]
Expand Down
33 changes: 0 additions & 33 deletions test/console-redirection-test.js

This file was deleted.

21 changes: 0 additions & 21 deletions test/test-helper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ let { randomBytes } = require("crypto");

let { exec, spawn } = require("./child_process");

let { Writable } = require("stream");

function generateRandomFilePath () {
return join(
tmpdir(),
Expand Down Expand Up @@ -57,26 +55,7 @@ function waitToExit (process) {
});
}

class WriteableBuffer extends Writable {
constructor (options) {
super(options);

this.chunks = [];
}

_write (chunk, encoding, callback) {
this.chunks.push(chunk);

callback();
}

getContents () {
return Buffer.concat(this.chunks);
}
}

module.exports = {
createKarmaTest,
waitToExit,
WriteableBuffer
};

0 comments on commit 1ae32f5

Please sign in to comment.