diff --git a/.travis.yml b/.travis.yml index 9144899aff6b..e8536f5a4d7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: node_js node_js: -- "0.10" +- "iojs-v1" +- "iojs-v2" sudo: false diff --git a/bin/jest.js b/bin/jest.js index 29c528413edb..12baa245116f 100755 --- a/bin/jest.js +++ b/bin/jest.js @@ -10,7 +10,6 @@ 'use strict'; var fs = require('fs'); -var harmonize = require('harmonize'); var optimist = require('optimist'); var path = require('path'); @@ -36,8 +35,6 @@ function _wrapDesc(desc) { }, ['']).join(indent); } -harmonize(); - var argv = optimist .usage('Usage: $0 [--config=] [TestPathRegExp]') .options({ diff --git a/package.json b/package.json index c8ac59d28c6d..2edd164c2edb 100644 --- a/package.json +++ b/package.json @@ -4,32 +4,30 @@ "version": "0.4.5", "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": "ide/coffeescript#array-check", + "cover": "^0.2.9", + "diff": "^1.4.0", + "graceful-fs": "^3.0.7", + "istanbul": "^0.3.14", + "jasmine-only": "^0.1.1", + "jasmine-pit": "^2.0.2", + "jsdom": "^5.4.2", "node-haste": "^1.2.8", - "node-worker-pool": "~2.4.2", - "optimist": "~0.6.0", - "q": "~0.9.7", - "resolve": "~0.6.1", - "through": "^2.3.4", - "lodash.template": "^3.0.0" + "node-worker-pool": "^2.4.4", + "optimist": "^0.6.1", + "q": "^1.4.1", + "resolve": "^1.1.6", + "through": "^2.3.7" }, "devDependencies": { - "jshint": "~2.5.0", - "node-find-files": "0.0.2" + "jshint": "^2.7.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", diff --git a/src/HasteModuleLoader/HasteModuleLoader.js b/src/HasteModuleLoader/HasteModuleLoader.js index 9b1a3d7a8f14..8b3958c4f749 100644 --- a/src/HasteModuleLoader/HasteModuleLoader.js +++ b/src/HasteModuleLoader/HasteModuleLoader.js @@ -129,15 +129,6 @@ function Loader(config, environment, resourceMap) { this._configShouldMockModuleNames = {}; 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(); } @@ -862,14 +853,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); @@ -1037,6 +1028,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), diff --git a/src/JSDomEnvironment.js b/src/JSDomEnvironment.js index a6efe560f926..a3163b515717 100644 --- a/src/JSDomEnvironment.js +++ b/src/JSDomEnvironment.js @@ -9,6 +9,8 @@ var FakeTimers = require('./lib/FakeTimers'); +var vm = require('vm'); + function _deepCopy(obj) { var newObj = {}; var value; @@ -29,7 +31,9 @@ function JSDomEnvironment(config) { // use it (depending on the context -- such as TestRunner.js when operating as // a workerpool parent), this is the best way to ensure we only spend time // require()ing this when necessary. - this.global = require('./lib/jsdom-compat').jsdom().parentWindow; + var jsdom = require('./lib/jsdom-compat'); + this.document = jsdom.jsdom(); + this.global = this.document.defaultView; // Node's error-message stack size is limited at 10, but it's pretty useful to // see more than that when a test fails. @@ -52,7 +56,6 @@ function JSDomEnvironment(config) { this.global.Uint32Array = Uint32Array; this.global.DataView = DataView; this.global.Buffer = Buffer; - this.global.process = process; this.global.setImmediate = setImmediate; this.global.clearImmediate = clearImmediate; @@ -104,8 +107,17 @@ JSDomEnvironment.prototype.dispose = function() { //this.global.close(); }; +/** + * Evaluates the given source text as if it were in a file with the given name + * and returns the result. + */ JSDomEnvironment.prototype.runSourceText = function(sourceText, fileName) { - return this.global.run(sourceText, fileName); + // TODO: Stop using the private API and instead configure jsdom with a + // resource loader and insert