Skip to content

Commit 7b7c8d9

Browse files
committed
use express.js server for tests; closes tastejs#1465
Use an express.js server for tests instead of http-server. The primary reason for this is that express has an available middleware that allows us to specificy the location of the favicon other than the root directory. This is needed because the favicon lives in the site-assets directory.
1 parent 828b6d1 commit 7b7c8d9

8 files changed

+16
-10
lines changed

.travis.yml

-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ before_install:
3030
- sh -e /etc/init.d/xvfb start
3131
- curl -Lo chrome.zip https://download-chromium.appspot.com/dl/Linux_x64 && unzip chrome.zip
3232
- curl -Lo chromedriver.zip http://chromedriver.storage.googleapis.com/2.18/chromedriver_linux64.zip && unzip chromedriver.zip
33-
before_script:
34-
- cp site-assets/favicon.ico favicon.ico
35-
- python -m SimpleHTTPServer > /dev/null 2>&1 &
36-
- sleep 2
3733
script:
3834
# We want to gate on passing tests and a successful build
3935
- ./test-runner.sh

gulpfile.js

+4
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,7 @@ gulp.task('pagespeed', pagespeed.bind(null, {
109109
gulp.task('serve', function (cb) {
110110
app.listen(8080, cb);
111111
});
112+
113+
gulp.task('test-server', function (cb) {
114+
app.listen(8000, cb);
115+
});

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"gulp-vulcanize": "^1.0.0",
3434
"jshint-stylish": "^1.0.0",
3535
"psi": "^0.1.1",
36-
"run-sequence": "^1.0.1"
36+
"run-sequence": "^1.0.1",
37+
"serve-favicon": "^2.3.0"
3738
}
3839
}

server.js

+2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ var fs = require('fs');
55
var learnJson = require('./learn.json');
66

77
var app = module.exports = express();
8+
var favicon = require('serve-favicon');
89

910
app.use(express.static(__dirname));
11+
app.use(favicon(__dirname + '/site-assets/favicon.ico'));
1012

1113
Object.defineProperty(module.exports, 'learnJson', {
1214
set: function (backend) {

test-runner.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ get_changes ()
99
git diff HEAD origin/master --name-only | awk 'BEGIN {FS = "/"}; {print $1 "/" $2 "/" $3}' | grep -v \/\/ | grep examples | awk -F '[/]' '{print "--framework=" $2}'|uniq
1010
}
1111

12+
npm i -g gulp
1213
if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]
1314
then
14-
npm i -g gulp
1515
gulp
1616
git submodule add -b gh-pages https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} site > /dev/null 2>&1
1717
cd site
@@ -35,6 +35,8 @@ else
3535
cd tooling && \
3636
echo $changes | xargs ./run.sh && \
3737
cd ../tests && \
38+
(gulp test-server &) && \
39+
sleep 2 && \ # give the server time to boot in the background
3840
echo $changes | xargs ./run.sh
3941
fi
4042

tests/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
npm-debug.log

tests/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ These tests use Selenium 2 (WebDriver), via the JavaScript API (WebdriverJS). I
2020
$ npm install
2121
```
2222

23-
You need to run a local server at the root of the TodoMVC project. Start the server using:
23+
If you haven't already run `npm install` in the root directory, execute `npm install` there as well.
24+
25+
You need to run a local server for the tests. Start the test server using:
2426

2527
```sh
26-
$ npm run serve
28+
$ gulp test-server
2729
```
2830

2931
To run the tests for all TodoMVC implementations, run the following:

tests/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
"private": true,
55
"devDependencies": {
66
"chromedriver": "^2.18.0",
7-
"http-server": "^0.7.5",
87
"mocha": "*",
98
"mocha-known-issues-reporter": "git+https://github.com/ColinEberhardt/mocha-known-issues-reporter.git#v0.0.0",
109
"optimist": "^0.6.1",
1110
"selenium-webdriver": "^2.46.1",
1211
"drool": "0.2.2"
1312
},
1413
"scripts": {
15-
"serve": "http-server -p 8000 ..",
1614
"test": "mocha allTests.js --no-timeouts --reporter spec"
1715
}
1816
}

0 commit comments

Comments
 (0)