Skip to content

Commit

Permalink
packages/jest-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitrii Abramov committed May 4, 2016
1 parent 1d778a1 commit f79bccd
Show file tree
Hide file tree
Showing 106 changed files with 209 additions and 141 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
.DS_STORE
.haste_cache
/node_modules
/examples/**/node_modules/
/packages/**/node_modules/
/examples/*/node_modules/
/packages/*/node_modules/
/website/node_modules
npm-debug.log
build
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ node_js:
- "6"
sudo: false
before_install: npm i -g npm@latest
install: npm i --ignore-scripts && npm run postinstall
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12.0.1
1 change: 0 additions & 1 deletion __integration_tests__/__tests__/coverage_report-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('coverage_report', () => {
it('outputs coverage report', () => {
const result = runJest('coverage_report', ['--coverage']);
const coverageDir = path.resolve(__dirname, '../coverage_report/coverage');

expect(result.stdout.toString()).toMatch(/All files.*100.*100.*100.*100/);
// this will throw if the coverage directory is not there
fs.accessSync(coverageDir, fs.F_OK);
Expand Down
3 changes: 2 additions & 1 deletion __integration_tests__/runJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

const spawnSync = require('child_process').spawnSync;
const path = require('path');
const JEST_PATH = path.resolve(__dirname, '../packages/jest-cli/bin/jest.js');

// return the result of the spawned proccess:
// [ 'status', 'signal', 'output', 'pid', 'stdout', 'stderr',
// 'envPairs', 'options', 'args', 'file' ]
module.exports = function runJest(dir, args) {
return spawnSync('jest', args || [], {
return spawnSync(JEST_PATH, args || [], {
cwd: path.resolve(__dirname, dir),
});
};
65 changes: 3 additions & 62 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
{
"name": "jest-cli",
"description": "Painless JavaScript Unit Testing.",
"version": "12.0.2",
"main": "src/jest.js",
"dependencies": {
"chalk": "^1.1.1",
"cover": "^0.2.9",
"diff": "^2.1.1",
"graceful-fs": "^4.1.3",
"istanbul": "^0.4.2",
"jest-environment-jsdom": "^12.0.2",
"jest-environment-node": "^12.0.2",
"jest-haste-map": "^12.0.2",
"jest-jasmine1": "^12.0.2",
"jest-jasmine2": "^12.0.2",
"jest-mock": "^12.0.2",
"jest-util": "^12.0.2",
"json-stable-stringify": "^1.0.0",
"lodash.template": "^4.2.4",
"mkdirp": "^0.5.1",
"optimist": "^0.6.1",
"resolve": "^1.1.6",
"sane": "^1.2.0",
"which": "^1.1.1",
"worker-farm": "^1.3.1"
},
"private": true,
"devDependencies": {
"babel-eslint": "^6.0.4",
"eslint": "^1.10.3",
Expand All @@ -33,43 +8,9 @@
"lerna": "^2.0.0-beta.6",
"rimraf": "^2.4.4"
},
"bin": {
"jest": "./bin/jest.js"
},
"engines": {
"node": ">= 4"
},
"repository": {
"type": "git",
"url": "https://github.com/facebook/jest"
},
"scripts": {
"lint": "eslint .",
"postinstall": "node postinstall.js",
"prepublish": "npm test",
"test": "node ./runTests.js"
},
"jest": {
"rootDir": "src",
"testPathIgnorePatterns": [
"/__tests__/[^/]*/.+"
],
"testEnvironment": "jest-environment-node",
"globals": {
"CACHE_DIRECTORY": "<rootDir>/../.haste_cache"
}
},
"bugs": {
"url": "https://github.com/facebook/jest/issues"
},
"homepage": "http://facebook.github.io/jest/",
"keywords": [
"facebook",
"jest",
"test",
"unit",
"jasmine",
"mock"
],
"license": "BSD-3-Clause"
"test": "npm run lint && node ./runTests.js"
}
}
3 changes: 2 additions & 1 deletion packages/babel-plugin-jest-hoist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
"main": "src/index.js",
"devDependencies": {
"babel-preset-es2015": "*",
"jest-util": "12.0.1",
"react": "^0.14.0"
},
"jest": {
"scriptPreprocessor": "../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../bin/jest.js"
"test": "../../packages/jest-cli/bin/jest.js"
}
}
36 changes: 36 additions & 0 deletions packages/jest-cli/__mocks__/jest-environment-jsdom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';

const vm = require.requireActual('vm');

const JSDOMEnvironment = jest.genMockFromModule('jest-environment-jsdom');

JSDOMEnvironment.mockImplementation(function(config) {
this.global = {
console: {},
mockClearTimers: jest.genMockFn(),
JSON,
};

const globalValues = Object.assign({}, config.globals);
for (const customGlobalKey in globalValues) {
this.global[customGlobalKey] = globalValues[customGlobalKey];
}
});

JSDOMEnvironment.prototype.runSourceText.mockImplementation(
function(sourceText, filename) {
return vm.runInNewContext(sourceText, this.global, {
filename,
displayErrors: false,
});
}
);

module.exports = JSDOMEnvironment;
File renamed without changes.
73 changes: 73 additions & 0 deletions packages/jest-cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"name": "jest-cli",
"description": "Painless JavaScript Unit Testing.",
"version": "12.0.2",
"main": "src/jest.js",
"dependencies": {
"chalk": "^1.1.1",
"cover": "^0.2.9",
"graceful-fs": "^4.1.3",
"istanbul": "^0.4.2",
"jest-environment-jsdom": "^11.0.2",
"jest-environment-node": "^11.0.2",
"jest-haste-map": "^11.0.2",
"jest-jasmine1": "^12.0.1",
"jest-jasmine2": "^12.0.1",
"jest-mock": "^11.0.2",
"jest-util": "^12.0.1",
"json-stable-stringify": "^1.0.0",
"lodash.template": "^4.2.4",
"mkdirp": "^0.5.1",
"optimist": "^0.6.1",
"resolve": "^1.1.6",
"sane": "^1.2.0",
"which": "^1.1.1",
"worker-farm": "^1.3.1"
},
"bin": {
"jest": "./bin/jest.js"
},
"engines": {
"node": ">= 4"
},
"repository": {
"type": "git",
"url": "https://github.com/facebook/jest"
},
"scripts": {
"jest-cache": "node bin/jest.js",
"jest-heap-usage": "node bin/jest.js --runInBand --logHeapUsage",
"jest-in-band": "node bin/jest.js --runInBand",
"jest-jasmine1": "node bin/jest.js --testRunner=jasmine1",
"jest-json": "node bin/jest.js --json",
"jest-no-cache": "node bin/jest.js --no-cache",
"jest-node-cache": "node bin/jest.js --no-watchman",
"jest-node-no-cache": "node bin/jest.js --no-watchman --no-cache",
"jest-verbose": "node bin/jest.js --verbose",
"lint": "eslint .",
"test": "./bin/jest.js"
},
"jest": {
"rootDir": "./src",
"testPathIgnorePatterns": [
"/__tests__/[^/]*/.+"
],
"testEnvironment": "jest-environment-node",
"globals": {
"CACHE_DIRECTORY": "<rootDir>/../.haste_cache"
}
},
"bugs": {
"url": "https://github.com/facebook/jest/issues"
},
"homepage": "http://facebook.github.io/jest/",
"keywords": [
"facebook",
"jest",
"test",
"unit",
"jasmine",
"mock"
],
"license": "BSD-3-Clause"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
'use strict';

jest.disableAutomock();
jest.mock('jest-environment-jsdom');
jest.mock(
'jest-environment-jsdom',
() => require('../../../__mocks__/jest-environment-jsdom')
);

const path = require('path');
const normalizeConfig = require('../../config/normalize');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
'use strict';

jest.disableAutomock();
jest.mock('jest-environment-jsdom');
jest.mock(
'jest-environment-jsdom',
() => require('../../../__mocks__/jest-environment-jsdom')
);

const path = require('path');
const normalizeConfig = require('../../config/normalize');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
'use strict';

jest.disableAutomock();
jest.mock('jest-environment-jsdom');
jest.mock(
'jest-environment-jsdom',
() => require('../../../__mocks__/jest-environment-jsdom')
);


const path = require('path');
const normalizeConfig = require('../../config/normalize');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
'use strict';

jest.disableAutomock();
jest.mock('jest-environment-jsdom');
jest.mock(
'jest-environment-jsdom',
() => require('../../../__mocks__/jest-environment-jsdom')
);

const path = require('path');
const normalizeConfig = require('../../config/normalize');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
'use strict';

jest.disableAutomock();
jest.mock('jest-environment-jsdom');
jest.mock(
'jest-environment-jsdom',
() => require('../../../__mocks__/jest-environment-jsdom')
);

const path = require('path');
const normalizeConfig = require('../../config/normalize');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
'use strict';

jest.disableAutomock();
jest.mock('jest-environment-jsdom');
jest.mock(
'jest-environment-jsdom',
() => require('../../../__mocks__/jest-environment-jsdom')
);

const path = require('path');
const normalizeConfig = require('../../config/normalize');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
'use strict';

jest.disableAutomock();
jest.mock('jest-environment-jsdom');
jest.mock(
'jest-environment-jsdom',
() => require('../../../__mocks__/jest-environment-jsdom')
);

const path = require('path');
const normalizeConfig = require('../../config/normalize');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
'use strict';

jest.disableAutomock();
jest.mock('jest-environment-jsdom');
jest.mock(
'jest-environment-jsdom',
() => require('../../../__mocks__/jest-environment-jsdom')
);

const path = require('path');
const normalizeConfig = require('../../config/normalize');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

jest.disableAutomock();

const formatter = new (require('jest-util/lib/JasmineFormatter'))(jasmine);
const formatter = new (require('jest-util').JasmineFormatter)(jasmine);
const CALLED_AT_LEAST_ONCE = 'Expected to be called at least once';
const SHOULD_NOT_BE_CALLED = 'Expected not to be called';
const NOT_EXPECTED_VALUES = (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
*/
'use strict';

jest.unmock('jest-util')
.unmock('../../constants')
.unmock('../normalize')
.unmock('chalk');
jest.disableAutomock();
jest.mock('../../lib/resolveNodeModule');

describe('normalize', () => {
let path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const utils = require('jest-util');
module.exports = {
automock: true,
bail: false,
cacheDirectory: path.resolve(__dirname, '..', '..', '.haste_cache'),
cacheDirectory: path.resolve(__dirname, '../..', '.haste_cache'),
coverageCollector: require.resolve('../IstanbulCollector'),
coverageReporters: ['json', 'text', 'lcov', 'clover'],
globals: {},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/jest-environment-jsdom/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/
'use strict';

const FakeTimers = require('jest-util/lib/FakeTimers');
const installCommonGlobals = require('jest-util/lib/installCommonGlobals');
const FakeTimers = require('jest-util').FakeTimers;
const installCommonGlobals = require('jest-util').installCommonGlobals;

class JSDOMEnvironment {

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-environment-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"testEnvironment": "node"
},
"scripts": {
"test": "../../bin/jest.js"
"test": "../../packages/jest-cli/bin/jest.js"
}
}
Loading

0 comments on commit f79bccd

Please sign in to comment.