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

[io.js] Update jsdom and get jest working on io.js #374

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: node_js
node_js:
- "0.10"
- "iojs-v1"
- "iojs-v2"
sudo: false
3 changes: 0 additions & 3 deletions bin/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
'use strict';

var fs = require('fs');
var harmonize = require('harmonize');
var optimist = require('optimist');
var path = require('path');

Expand All @@ -36,8 +35,6 @@ function _wrapDesc(desc) {
}, ['']).join(indent);
}

harmonize();

var argv = optimist
.usage('Usage: $0 [--config=<pathToConfigFile>] [TestPathRegExp]')
.options({
Expand Down
35 changes: 17 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,31 @@
"version": "0.4.13",
"main": "src/jest.js",
"dependencies": {
"coffee-script": "^1.8.0",
"cover": "~0.2.8",
"diff": "~1.0.4",
"graceful-fs": "^2.0.3",
"harmonize": "1.4.2",
"istanbul": "^0.3.2",
"jasmine-only": "0.1.0",
"jasmine-pit": "~2.0.0",
"jsdom": "~0.10.3",
"coffee-script": "jashkenas/coffeescript",
"cover": "^0.2.9",
"diff": "^1.4.0",
"graceful-fs": "^3.0.8",
"istanbul": "^0.3.15",
"jasmine-only": "^0.1.1",
"jasmine-pit": "^2.0.2",
"jsdom": "^5.4.3",
"lodash.template": "^3.6.1",
"node-haste": "^1.2.8",
"node-worker-pool": "~2.4.2",
"optimist": "~0.6.0",
"bluebird": "~2.9.30",
"resolve": "~0.6.1",
"through": "^2.3.4",
"lodash.template": "^3.0.0"
"node-worker-pool": "^2.4.4",
"optimist": "^0.6.1",
"bluebird": "^2.9.30",
"resolve": "^1.1.6",
"through": "^2.3.7"
},
"devDependencies": {
"jshint": "~2.5.0",
"node-find-files": "0.0.2"
"jshint": "^2.8.0",
"node-find-files": "0.0.4"
},
"bin": {
"jest": "./bin/jest.js"
},
"engines": {
"node": "0.8.x || 0.10.x"
"node": ">= 1"
},
"repository": {
"type": "git",
Expand Down
23 changes: 9 additions & 14 deletions src/HasteModuleLoader/HasteModuleLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,6 @@ function Loader(config, environment, resourceMap) {
}

if (_configUnmockListRegExpCache === null) {
// Node must have been run with --harmony in order for WeakMap to be
// available prior to version 0.12
if (typeof WeakMap !== 'function') {
throw new Error(
'Please run node with the --harmony flag! jest requires WeakMap ' +
'which is only available with the --harmony flag in node < v0.12'
);
}

_configUnmockListRegExpCache = new WeakMap();
}

Expand Down Expand Up @@ -243,7 +234,7 @@ Loader.prototype._execModule = function(moduleObj) {
this._isCurrentlyExecutingManualMock = modulePath;

utils.runContentWithLocalBindings(
this._environment.runSourceText.bind(this._environment),
this._environment,
moduleContent,
modulePath,
moduleLocalBindings
Expand Down Expand Up @@ -860,14 +851,14 @@ Loader.prototype.requireModule = function(currPath, moduleName,
modulePath = manualMockResource.path;
}

if (!modulePath) {
modulePath = this._moduleNameToPath(currPath, moduleName);
}

if (NODE_CORE_MODULES[moduleName]) {
return require(moduleName);
}

if (!modulePath) {
modulePath = this._moduleNameToPath(currPath, moduleName);
}

// Always natively require the jasmine runner.
if (modulePath.indexOf(VENDOR_PATH) === 0) {
return require(modulePath);
Expand Down Expand Up @@ -1035,6 +1026,10 @@ Loader.prototype.resetModuleRegistry = function() {
this._environment.fakeTimers.runAllTicks();
}.bind(this),

runAllImmediates: function() {
this._environment.fakeTimers.runAllImmediates();
}.bind(this),

runAllTimers: function() {
this._environment.fakeTimers.runAllTimers();
}.bind(this),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
'use strict';

jest.autoMockOff();
jest.mock('../../JSDomEnvironment');

var path = require('path');
var Promise = require('bluebird');
var utils = require('../../lib/utils');

describe('HasteModuleLoader', function() {
var HasteModuleLoader;
var mockEnvironment;
var JSDomEnvironment;
var resourceMap;

var CONFIG = utils.normalizeConfig({
Expand All @@ -30,6 +31,7 @@ describe('HasteModuleLoader', function() {
return buildLoader();
});
} else {
var mockEnvironment = new JSDomEnvironment(CONFIG);
return Promise.resolve(
new HasteModuleLoader(CONFIG, mockEnvironment, resourceMap)
);
Expand All @@ -39,16 +41,7 @@ describe('HasteModuleLoader', function() {
function initHasteModuleLoader(nodePath) {
process.env.NODE_PATH = nodePath;
HasteModuleLoader = require('../HasteModuleLoader');
mockEnvironment = {
global: {
console: {},
mockClearTimers: jest.genMockFn()
},
runSourceText: jest.genMockFn().mockImplementation(function(codeStr) {
/* jshint evil:true */
return (new Function('return ' + codeStr))();
})
};
JSDomEnvironment = require('../../JSDomEnvironment');
}

pit('uses NODE_PATH to find modules', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ describe('nodeHasteModuleLoader', function() {
expect(jest.currentTestPath()).toMatch(/currentTestPath-test/);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
'use strict';

jest.autoMockOff();
jest.mock('../../JSDomEnvironment');

var path = require('path');
var Promise = require('bluebird');
var utils = require('../../lib/utils');

describe('nodeHasteModuleLoader', function() {
var HasteModuleLoader;
var mockEnvironment;
var JSDomEnvironment;
var resourceMap;

var CONFIG = utils.normalizeConfig({
Expand All @@ -30,6 +31,7 @@ describe('nodeHasteModuleLoader', function() {
return buildLoader();
});
} else {
var mockEnvironment = new JSDomEnvironment(CONFIG);
return Promise.resolve(
new HasteModuleLoader(CONFIG, mockEnvironment, resourceMap)
);
Expand All @@ -38,17 +40,7 @@ describe('nodeHasteModuleLoader', function() {

beforeEach(function() {
HasteModuleLoader = require('../HasteModuleLoader');

mockEnvironment = {
global: {
console: {},
mockClearTimers: jest.genMockFn()
},
runSourceText: jest.genMockFn().mockImplementation(function(codeStr) {
/* jshint evil:true */
return (new Function('return ' + codeStr))();
})
};
JSDomEnvironment = require('../../JSDomEnvironment');
});

describe('genMockFromModule', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'use strict';

jest.autoMockOff();
jest.mock('../../JSDomEnvironment');

describe('nodeHasteModuleLoader', function() {
var HasteModuleLoader;
Expand Down Expand Up @@ -42,18 +43,10 @@ describe('nodeHasteModuleLoader', function() {
}

beforeEach(function() {
var JSDomEnvironment = require('../../JSDomEnvironment');
HasteModuleLoader = require('../HasteModuleLoader');

mockEnvironment = {
global: {
console: {},
mockClearTimers: jest.genMockFn()
},
runSourceText: jest.genMockFn().mockImplementation(function(codeStr) {
/* jshint evil: true */
return (new Function('return ' + codeStr))();
})
};
mockEnvironment = new JSDomEnvironment(mockConfig);
resources = {};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
'use strict';

jest.autoMockOff();
jest.mock('../../JSDomEnvironment');

var path = require('path');
var Promise = require('bluebird');
var utils = require('../../lib/utils');

describe('HasteModuleLoader', function() {
var HasteModuleLoader;
var mockEnvironment;
var JSDomEnvironment;
var resourceMap;

var CONFIG = utils.normalizeConfig({
Expand All @@ -30,6 +31,7 @@ describe('HasteModuleLoader', function() {
return buildLoader();
});
} else {
var mockEnvironment = new JSDomEnvironment(CONFIG);
return Promise.resolve(
new HasteModuleLoader(CONFIG, mockEnvironment, resourceMap)
);
Expand All @@ -38,17 +40,7 @@ describe('HasteModuleLoader', function() {

beforeEach(function() {
HasteModuleLoader = require('../HasteModuleLoader');

mockEnvironment = {
global: {
console: {},
mockClearTimers: jest.genMockFn()
},
runSourceText: jest.genMockFn().mockImplementation(function(codeStr) {
/* jshint evil:true */
return (new Function('return ' + codeStr))();
})
};
JSDomEnvironment = require('../../JSDomEnvironment');
});

describe('requireMock', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
'use strict';

jest.autoMockOff();
jest.mock('../../JSDomEnvironment');

var path = require('path');
var Promise = require('bluebird');
var utils = require('../../lib/utils');

describe('HasteModuleLoader', function() {
var HasteModuleLoader;
var mockEnvironment;
var JSDomEnvironment;
var resourceMap;

var CONFIG = utils.normalizeConfig({
Expand All @@ -30,6 +31,7 @@ describe('HasteModuleLoader', function() {
return buildLoader();
});
} else {
var mockEnvironment = new JSDomEnvironment(CONFIG);
return Promise.resolve(
new HasteModuleLoader(CONFIG, mockEnvironment, resourceMap)
);
Expand All @@ -38,18 +40,7 @@ describe('HasteModuleLoader', function() {

beforeEach(function() {
HasteModuleLoader = require('../HasteModuleLoader');

mockEnvironment = {
global: {
console: {},
mockClearTimers: jest.genMockFn(),
JSON: JSON
},
runSourceText: jest.genMockFn().mockImplementation(function(codeStr) {
/* jshint evil:true */
return (new Function('return ' + codeStr))();
})
};
JSDomEnvironment = require('../../JSDomEnvironment');
});

describe('requireModule', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
'use strict';

jest.autoMockOff();
jest.mock('../../JSDomEnvironment');

var path = require('path');
var Promise = require('bluebird');
var utils = require('../../lib/utils');

describe('HasteModuleLoader', function() {
var HasteModuleLoader;
var mockEnvironment;
var JSDomEnvironment;
var resourceMap;

var CONFIG = utils.normalizeConfig({
Expand All @@ -30,6 +31,7 @@ describe('HasteModuleLoader', function() {
return buildLoader();
});
} else {
var mockEnvironment = new JSDomEnvironment(CONFIG);
return Promise.resolve(
new HasteModuleLoader(CONFIG, mockEnvironment, resourceMap)
);
Expand All @@ -38,17 +40,7 @@ describe('HasteModuleLoader', function() {

beforeEach(function() {
HasteModuleLoader = require('../HasteModuleLoader');

mockEnvironment = {
global: {
console: {},
mockClearTimers: jest.genMockFn()
},
runSourceText: jest.genMockFn().mockImplementation(function(codeStr) {
/* jshint evil:true */
return (new Function('return ' + codeStr))();
})
};
JSDomEnvironment = require('../../JSDomEnvironment');
});

describe('requireModuleOrMock', function() {
Expand Down
Loading