Skip to content

Commit a747699

Browse files
author
Robert Jackson
authored
Merge pull request #18 from ember-codemods/custom-console
Add console override for tests.
2 parents 5682fd7 + d73d7a2 commit a747699

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

test/helpers.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
const CONSOLE = Object.assign({}, console);
4+
5+
let consoleOutput;
6+
7+
function setupConsole() {
8+
consoleOutput = [];
9+
10+
console.info = function () {
11+
consoleOutput.push(...arguments);
12+
};
13+
}
14+
15+
function resetConsole() {
16+
Object.assign(console, CONSOLE);
17+
consoleOutput = undefined;
18+
}
19+
20+
function getConsoleOutput() {
21+
return consoleOutput;
22+
}
23+
24+
module.exports = {
25+
setupConsole,
26+
getConsoleOutput,
27+
resetConsole,
28+
};

test/lib/migrator/classic-to-flat-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ const fixturify = require('fixturify');
33
const fse = require('fs-extra');
44
const path = require('path');
55
const Migrator = require('../../../lib/migrator');
6+
const { setupConsole, resetConsole } = require('../../helpers');
67

78
assertDiff.options.strict = true;
89

910
describe('structure = flat', function () {
1011
beforeEach(function () {
1112
this.tmpPath = 'tmp/process-files';
1213
fse.mkdirsSync(this.tmpPath);
14+
setupConsole();
1315
});
1416

1517
afterEach(function () {
1618
fse.removeSync(this.tmpPath);
19+
resetConsole();
1720
});
1821

1922
describe('For an app with component classes written in JavaScript', function () {

0 commit comments

Comments
 (0)