forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run tests for all packages and example projects
Summary: Closes jestjs#822 Differential Revision: D3104247 fb-gh-sync-id: 4513775f0b824084b9ab1f730af73b31d758c39b fbshipit-source-id: 4513775f0b824084b9ab1f730af73b31d758c39b
- Loading branch information
Dmitrii Abramov
authored and
Facebook Github Bot 9
committed
Mar 28, 2016
1 parent
9c978bb
commit 3ec2df5
Showing
10 changed files
with
96 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_js: | |
- "4" | ||
- "5" | ||
sudo: false | ||
before_install: npm i -g npm@latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"devDependencies": { | ||
"jest-cli": "*" | ||
}, | ||
"scripts": { | ||
"test": "node ../../bin/jest.js" | ||
"test": "jest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"devDependencies": { | ||
"jest-cli": "*" | ||
}, | ||
"scripts": { | ||
"test": "node ../../bin/jest.js" | ||
"test": "jest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"devDependencies": { | ||
"jest-cli": "*" | ||
}, | ||
"scripts": { | ||
"test": "node ../../bin/jest.js" | ||
"test": "jest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
{ | ||
"devDependencies": { | ||
"jest-cli": "*" | ||
}, | ||
"dependencies": { | ||
"jquery": "*" | ||
}, | ||
"scripts": { | ||
"test": "node ../../bin/jest.js" | ||
"test": "jest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Copyright (c) 2014, 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. | ||
*/ | ||
|
||
/** | ||
* This script runs tests for all packages in `./packages` and | ||
* example projects in `./examples`. | ||
*/ | ||
|
||
const fs = require('graceful-fs'); | ||
const path = require('path'); | ||
const chalk = require('chalk'); | ||
const execSync = require('child_process').execSync; | ||
|
||
const PACKAGES_DIR = './packages'; | ||
const EXAMPLES_DIR = './examples'; | ||
|
||
const packages = fs.readdirSync(PACKAGES_DIR) | ||
.map(file => path.resolve(PACKAGES_DIR, file)) | ||
.filter(f => fs.lstatSync(path.resolve(f)).isDirectory()); | ||
|
||
const examples = fs.readdirSync(EXAMPLES_DIR) | ||
.map(file => path.resolve(EXAMPLES_DIR, file)) | ||
.filter(f => fs.lstatSync(path.resolve(f)).isDirectory()); | ||
|
||
function runCommands(commands, cwd) { | ||
commands = [].concat(commands); | ||
commands.forEach(cmd => { | ||
console.log(chalk.green('-> ') + chalk.underline.bold('running:') + | ||
' ' + chalk.bold.cyan(cmd)); | ||
execSync(cmd, { | ||
cwd, | ||
stdio: [0, 1, 2], | ||
}); | ||
}); | ||
} | ||
|
||
packages.forEach(cwd => { | ||
console.log(chalk.bold(chalk.cyan('Testing package: ') + cwd)); | ||
runCommands('npm test', cwd); | ||
}); | ||
|
||
examples.forEach(cwd => { | ||
console.log(chalk.bold(chalk.cyan('Testing example: ') + cwd)); | ||
|
||
runCommands([ | ||
'npm update', | ||
'rm -rf ./node_modules/jest-cli', | ||
'mkdir -p ./node_modules/jest-cli', | ||
'mkdir -p ./node_modules/.bin', | ||
], cwd); | ||
|
||
// Using `npm link jest-cli` can create problems with module resolution, | ||
// so instead of this we'll create an `index.js` file that will export the | ||
// local `jest-cli` package. | ||
fs.writeFileSync( | ||
path.resolve(cwd, './node_modules/jest-cli/index.js'), | ||
`module.exports = require('../../../../');\n`, // link to the local jest | ||
'utf8' | ||
); | ||
|
||
// overwrite the jest link and point it to the local jest-cli | ||
runCommands( | ||
['ln -sf ../../bin/jest.js ./node_modules/.bin/jest', 'npm test'], | ||
cwd | ||
); | ||
}); |