Skip to content

Commit

Permalink
single jest run for all packages
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabramov committed Aug 3, 2016
1 parent 6ea16b5 commit a205e91
Show file tree
Hide file tree
Showing 27 changed files with 44 additions and 142 deletions.
6 changes: 4 additions & 2 deletions integration_tests/__tests__/coverage_report-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ const runJest = require('../runJest');
const fs = require('fs');
const path = require('path');

const DIR = path.resolve(__dirname, '../coverage_report');

it('outputs coverage report', () => {
const {stdout, status} = runJest('coverage_report', ['--coverage']);
const {stdout, status} = runJest(DIR, ['--coverage']);
const coverageDir = path.resolve(__dirname, '../coverage_report/coverage');

// should be no `setup.file` in the coverage report. It's ignored
Expand All @@ -26,7 +28,7 @@ it('outputs coverage report', () => {
});

it('collects coverage only from specified files', () => {
const {stdout} = runJest('coverage_report', [
const {stdout} = runJest(DIR, [
'--coverage',
'--collectCoverageFrom', // overwrites the one in package.json
'setup.js',
Expand Down
5 changes: 4 additions & 1 deletion integration_tests/__tests__/empty_suite_error-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

'use strict';

const path = require('path');
const runJest = require('../runJest');

const DIR = path.resolve(__dirname, '../empty_suite_error');

describe('JSON Reporter', () => {
it('fails the test suite if it contains no tests', () => {
const result = runJest('empty_suite_error', []);
const result = runJest(DIR, []);
const stderr = result.stderr.toString();
expect(stderr).toMatch('Runtime Error');
expect(stderr).toMatch(
Expand Down
8 changes: 7 additions & 1 deletion integration_tests/runJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const JEST_PATH = path.resolve(__dirname, '../packages/jest-cli/bin/jest.js');
// [ 'status', 'signal', 'output', 'pid', 'stdout', 'stderr',
// 'envPairs', 'options', 'args', 'file' ]
function runJest(dir, args) {
const isRelative = dir[0] !== '/';

if (isRelative) {
dir = path.resolve(__dirname, dir);
}

const localPackageJson = path.resolve(dir, 'package.json');
if (!fileExists(localPackageJson)) {
throw new Error(`
Expand All @@ -27,7 +33,7 @@ function runJest(dir, args) {
}

const result = spawnSync(JEST_PATH, args || [], {
cwd: path.resolve(__dirname, dir),
cwd: dir,
});

result.stdout = result.stdout && result.stdout.toString();
Expand Down
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,18 @@
"test": "npm run typecheck && npm run lint && npm run build && npm run t",
"typecheck": "flow check",
"watch": "npm run build; node ./scripts/watch.js"
},
"jest": {
"rootDir": "./",
"scriptPreprocessor": "<rootDir>/packages/babel-jest",
"automock": false,
"testPathIgnorePatterns": [
"/node_modules/",
"/examples/",
"integration_tests\/.*\/__tests__",
"\\.snap$",
"packages\/.*\/build"
],
"testRegex": ".*-test.\\js"
}
}
5 changes: 0 additions & 5 deletions packages/babel-plugin-jest-hoist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
"babel-preset-es2015": "*",
"react": "^0.14.0"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
5 changes: 0 additions & 5 deletions packages/jest-changed-files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
"devDependencies": {
"rimraf": "^2.5.2"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
8 changes: 0 additions & 8 deletions packages/jest-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@
"scripts": {
"test": "./bin/jest.js"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node",
"testPathIgnorePatterns": [
"/__tests__/[^/]*/.+"
]
},
"bugs": {
"url": "https://github.com/facebook/jest/issues"
},
Expand Down
5 changes: 0 additions & 5 deletions packages/jest-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
"jest-util": "^14.0.0",
"json-stable-stringify": "^1.0.0"
},
"jest": {
"rootDir": "./build",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "jest-environment-node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
6 changes: 0 additions & 6 deletions packages/jest-diff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
"jest-matcher-utils": "^14.0.0",
"pretty-format": "^3.5.0"
},
"jest": {
"automock": false,
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
5 changes: 0 additions & 5 deletions packages/jest-environment-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
"dependencies": {
"jest-util": "^14.0.0"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
6 changes: 0 additions & 6 deletions packages/jest-file-exists/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
},
"license": "BSD-3-Clause",
"main": "build/index.js",
"jest": {
"automock": false,
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
5 changes: 0 additions & 5 deletions packages/jest-haste-map/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
"graceful-fs": "^4.1.3",
"worker-farm": "^1.3.1"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-haste-map/src/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/
'use strict';

jest.enableAutomock();

jest.unmock('../constants')
.unmock('../lib/docblock')
.unmock('../lib/extractRequires')
Expand Down
5 changes: 0 additions & 5 deletions packages/jest-jasmine2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
"jest-snapshot": "^14.0.0",
"jest-util": "^14.0.0"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
5 changes: 0 additions & 5 deletions packages/jest-matcher-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
},
"license": "BSD-3-Clause",
"main": "build/index.js",
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
6 changes: 0 additions & 6 deletions packages/jest-matchers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
"devDependencies": {
"strip-ansi": "^3.0.1"
},
"jest": {
"automock": false,
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
5 changes: 0 additions & 5 deletions packages/jest-mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
},
"license": "BSD-3-Clause",
"main": "build/index.js",
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
5 changes: 0 additions & 5 deletions packages/jest-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
"dependencies": {
"react-native": "0.30.0"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
6 changes: 0 additions & 6 deletions packages/jest-repl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
"bin": {
"jest-repl": "./bin/jest-repl.js"
},
"jest": {
"automock": false,
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
5 changes: 0 additions & 5 deletions packages/jest-resolve-dependencies/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
"jest-file-exists": "^14.0.0",
"jest-resolve": "^14.1.0"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
5 changes: 0 additions & 5 deletions packages/jest-resolve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
"jest-haste-map": "^14.1.0",
"resolve": "^1.1.6"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
16 changes: 2 additions & 14 deletions packages/jest-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,8 @@
},
"devDependencies": {
"jest-config": "^14.1.0",
"jest-environment-node": "^14.0.0"
},
"jest": {
"automock": false,
"preprocessorIgnorePatterns": [
"node_modules"
],
"rootDir": "./src",
"scriptPreprocessor": "<rootDir>/../../babel-jest",
"setupTestFrameworkScriptFile": "<rootDir>/__mocks__/env.js",
"testEnvironment": "node",
"testPathIgnorePatterns": [
"/__tests__/[^/]*/.+"
]
"jest-environment-node": "^14.0.0",
"jest-environment-jsdom": "^14.0.0"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-runtime/src/__tests__/Runtime-cli-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/
'use strict';

require('../__mocks__/env.js');

const spawnSync = require('child_process').spawnSync;
const path = require('path');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
exports[`transform transforms a file properly 1`] = `
"({\"Object.<anonymous>\":function(module,exports,require,__dirname,__filename,global,jest){module.exports = \"banana\";
"({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){module.exports = "banana";
}});"
`;

exports[`transform transforms a file properly 2`] = `
"({\"Object.<anonymous>\":function(module,exports,require,__dirname,__filename,global,jest){module.exports = () => \"kiwi\";
"({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){module.exports = () => "kiwi";
}});"
`;

exports[`transform uses the supplied preprocessor 1`] = `
"({\"Object.<anonymous>\":function(module,exports,require,__dirname,__filename,global,jest){
"({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){
const TRANSFORMED = {
filename: \'/fruits/banana.js\',
script: \'module.exports = \"banana\";\',
config: \'{\"cache\":true,\"cacheDirectory\":\"/cache/\",\"name\":\"test\",\"preprocessorIgnorePatterns\":[\"/node_modules/\"],\"scriptPreprocessor\":\"test-preprocessor\"}\',
filename: '/fruits/banana.js',
script: 'module.exports = "banana";',
config: '{"cache":true,"cacheDirectory":"/cache/","name":"test","preprocessorIgnorePatterns":["/node_modules/"],"scriptPreprocessor":"test-preprocessor"}',
};
}});"
`;

exports[`transform uses the supplied preprocessor 2`] = `
"({\"Object.<anonymous>\":function(module,exports,require,__dirname,__filename,global,jest){module.exports = \"react\";
"({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){module.exports = "react";
}});"
`;
5 changes: 0 additions & 5 deletions packages/jest-snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
"jest-util": "^14.0.0",
"pretty-format": "^3.5.0"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../jest-cli/bin/jest.js"
}
Expand Down
5 changes: 0 additions & 5 deletions packages/jest-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
"devDependencies": {
"jsdom": "^9.2.1"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js"
}
Expand Down
Loading

0 comments on commit a205e91

Please sign in to comment.