Skip to content

Commit

Permalink
test(rewire): remove rewire dep and related code, override process via
Browse files Browse the repository at this point in the history
Object.assign instead
  • Loading branch information
tmcgee123 committed Jan 12, 2022
1 parent 334f51b commit 2ffcf93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"mocha": "^3.2.0",
"mocha-runner": "^1.1.1",
"npm-run-all": "^4.0.2",
"rewire": "^2.5.1",
"sinon": "^1.17.2",
"sinon-chai": "^2.8.0"
},
Expand Down
25 changes: 11 additions & 14 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@

/* jshint ignore:end */

var rewire = require('rewire');
var chai = require('chai');
var sinon = require('sinon');
var sinonChai = require('sinon-chai');
chai.use(sinonChai);
var should = chai.should();
var expect = chai.expect;
var os = require('os');
var reporterRewire = rewire('../index.js');
var SpecReporter = require('../index.js')['reporter:spec'];

var ansiColors = {
Expand All @@ -65,24 +63,23 @@ var baseReporterDecorator = function(context) {
context.writeCommonMsg = sinon.spy();
context.write = sinon.spy();
};

var originalPlatform = '';
describe('SpecReporter', function() {
describe('when initializing', function() {
describe('and on a windows machine', function() {
after(function(done){
Object.defineProperty(process, 'platform', {
value: originalPlatform
});
done();
})
function createSpecReporter(config) {
config = config || {};
var processMock = {
platform: function() {
return 'win32';
}
};
reporterRewire.__set__({
'reporter:spec': SpecReporter,
process: {
platform: 'win32'
}
originalPlatform = process.platform;
Object.defineProperty(process, 'platform', {
value: 'win32'
});
return new reporterRewire['reporter:spec'][1](baseReporterDecorator, formatError, config);
return new SpecReporter[1](baseReporterDecorator, formatError, config);
}

it('SpecReporter should have icons defined appropriately', function() {
Expand Down

0 comments on commit 2ffcf93

Please sign in to comment.