-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a shortcut option to redirect jsdom's sandboxed console to node's console.
- Loading branch information
Showing
3 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
let { createKarmaTest, waitToExit, WriteableBuffer } = require("./test-helper"); | ||
|
||
describe("with redirectConsole: true", function () { | ||
it("should redirect console from jsdom to node", async function () { | ||
let process = await createKarmaTest({ redirectConsole: true }, function () { | ||
console.log("foo bar"); | ||
}); | ||
|
||
let writable = process.stdout.pipe(new WriteableBuffer()); | ||
|
||
await waitToExit(process); | ||
|
||
if (writable.getContents().toString().indexOf("foo bar") === -1) { | ||
throw new Error("Expected stdout to contain 'foo bar'"); | ||
} | ||
}); | ||
}); | ||
|
||
describe("with redirectConsole: false (default)", function () { | ||
it("should omit console output from jsdom", async function () { | ||
let process = await createKarmaTest({}, function () { | ||
console.log("foo bar"); | ||
}); | ||
|
||
let writable = process.stdout.pipe(new WriteableBuffer()); | ||
|
||
await waitToExit(process); | ||
|
||
if (writable.getContents().toString().indexOf("foo bar") !== -1) { | ||
throw new Error("Expected stdout to not contain 'foo bar'"); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters