Skip to content

Commit 4f5a6ea

Browse files
committed
Speed up single unit test
1 parent f47e76d commit 4f5a6ea

File tree

6 files changed

+34
-12
lines changed

6 files changed

+34
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ node_modules/
33
bower_components/
44
build/*
55
examples/blog/build/*
6+
src/
7+
jest.lastrun

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ install:
55
@./node_modules/protractor/bin/webdriver-manager update
66
mkdir -p examples/blog/build/
77

8+
postinstall:
9+
mv node_modules/react-medium-editor node_modules/react-medium-editor_es6
10+
./node_modules/babel/bin/babel/index.js node_modules/react-medium-editor_es6 --out-dir node_modules/react-medium-editor --stage 1 --compact false > /dev/null
11+
mv node_modules/admin-config node_modules/admin-config_es6
12+
./node_modules/babel/bin/babel/index.js node_modules/admin-config_es6 --out-dir node_modules/admin-config --stage 1 --compact false > /dev/null
13+
rm -rf node_modules/react-medium-editor_es6
14+
rm -rf node_modules/admin-config_es6
15+
816
build:
917
@NODE_ENV=production ./node_modules/webpack/bin/webpack.js -p --optimize-minimize --optimize-occurence-order --optimize-dedupe --progress
1018
@cp -Rf build/* examples/blog/build/
@@ -28,17 +36,9 @@ run-test-e2e: start-test-server test-e2e stop-test-server
2836

2937
test-unit-init:
3038
./node_modules/babel/bin/babel/index.js app --out-dir src --stage 1 --compact false > /dev/null
31-
mv node_modules/react-medium-editor node_modules/react-medium-editor_es6
32-
./node_modules/babel/bin/babel/index.js node_modules/react-medium-editor_es6 --out-dir node_modules/react-medium-editor --stage 1 --compact false > /dev/null
33-
mv node_modules/admin-config node_modules/admin-config_es6
34-
./node_modules/babel/bin/babel/index.js node_modules/admin-config_es6 --out-dir node_modules/admin-config --stage 1 --compact false > /dev/null
3539

3640
test-unit-clean:
37-
rm -rf node_modules/react-medium-editor
38-
rm -rf node_modules/admin-config
3941
rm -rf ./src
40-
mv node_modules/react-medium-editor_es6 node_modules/react-medium-editor
41-
mv node_modules/admin-config_es6 node_modules/admin-config
4242

4343
test-unit-run:
4444
@./node_modules/jest-cli/bin/jest.js src

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,14 @@ Launch the entire tests suite by calling:
113113
make test
114114
```
115115

116+
Run only unit tests suite:
117+
118+
```sh
119+
make test-unit
120+
```
121+
116122
Run only one unit test by calling, for example:
117123

118124
```
119-
./node_modules/jest-cli/bin/jest.js -c jest.json app/__tests__/autoloaderTest.js
125+
./test-unit-single.sh __tests__/autoloaderTest.js
120126
```

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"webpack-dev-server": "^1.9.0"
4747
},
4848
"scripts": {
49+
"postinstall": "make postinstall",
4950
"test": "make test"
5051
},
5152
"keywords": [

test-unit-single.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
if [ ! -d ./src ]
4+
then
5+
touch jest.lastrun
6+
./node_modules/babel/bin/babel/index.js app --out-dir src --stage 1 --compact false > /dev/null
7+
else
8+
for i in `find app -type f -newer jest.lastrun`
9+
do
10+
./node_modules/babel/bin/babel/index.js $i --out-file `echo $i | sed 's#^app#src#'`
11+
done
12+
touch jest.lastrun
13+
fi
14+
15+
./node_modules/jest-cli/bin/jest.js src/$1

webpack.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ module.exports = {
6565
},
6666
module: {
6767
loaders: [
68-
{ test: /admin-config/, loaders: ['babel?stage=1&optional[]=runtime'] },
69-
{ test: /\.js$/, loaders: ['react-hot', 'babel?stage=1&optional[]=runtime'], exclude: /node_modules/ },
7068
{ test: /react-router\/.*\.js$/, loader: 'babel'},
71-
{ test: /react-medium-editor\/.*\.js$/, loader: 'babel'},
69+
{ test: /\.js$/, loaders: ['react-hot', 'babel?stage=1&optional[]=runtime'], exclude: /node_modules/ },
7270
{ test: /\.css$/, loader: ExtractTextPlugin.extract('css') },
7371
{ test: /\.scss$/, loader: ExtractTextPlugin.extract('css!sass') },
7472
{ test: /\.jpe?g$|\.gif$|\.png$|\.svg$|\.woff2?$|\.ttf|\.eot$/, loader: 'url' }

0 commit comments

Comments
 (0)