Skip to content

Commit a589015

Browse files
committed
test(): start config for protractor
1 parent 015f8f6 commit a589015

File tree

5 files changed

+61
-1
lines changed

5 files changed

+61
-1
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ before_script:
5353

5454
script:
5555
- ./scripts/ci/build-and-test.sh ${MODE}
56+
- ./scripts/ci/test-e2e-js.sh
5657

5758
cache:
5859
directories:

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
"karma-firefox-launcher": "^0.1.7",
4242
"karma-jasmine": "^0.3.6",
4343
"karma-sauce-launcher": "^0.2.14",
44-
"typescript": "^1.7.5"
44+
"protractor": "^3.0.0",
45+
"typescript": "^1.7.5",
46+
"webdriver-manager": "^8.0.0"
4547
}
4648
}

scripts/ci/test-e2e-js.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
echo =============================================================================
5+
# go to project dir
6+
SCRIPT_DIR=$(dirname $0)
7+
cd ${SCRIPT_DIR}/../..
8+
9+
./node_modules/.bin/webdriver-manager update
10+
11+
function killServer () {
12+
kill $serverPid
13+
}
14+
15+
16+
./node_modules/.bin/ng serve&
17+
serverPid=$!
18+
19+
# If this scipt is killed, ensure that the server is terminated.
20+
trap killServer EXIT
21+
22+
# Wait for server to come up!
23+
sleep 10
24+
25+
# Let protractor use default browser unless one is specified.
26+
OPTIONS="";
27+
if [[ -n "$E2E_BROWSERS" ]]; then
28+
OPTIONS="--browsers=$E2E_BROWSERS";
29+
fi
30+
31+
./node_modules/.bin/protractor test/protractor-js.conf.js ${OPTIONS}

src/e2e/button-e2e-spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
describe('protractor sanity test', function() {
2+
var url = 'index.html';
3+
4+
beforeEach(() => { browser.get(url); });
5+
6+
it('should sanity check the demo-app', () => {
7+
var button = element.all(by.css('button')).first();
8+
expect(button.getAttribute('md-button')).toBeDefined();
9+
});
10+
});

test/protractor-js.conf.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Configuration for running e2e tests with Protractor.
3+
*/
4+
exports.config = {
5+
framework: 'jasmine2',
6+
useAllAngular2AppRoots: true,
7+
8+
baseUrl: 'http://localhost:4200/',
9+
specs: ['../dist/e2e/button-e2e-spec.js'],
10+
11+
// Specific options for jasmine.
12+
jasmineNodeOpts: {
13+
showColors: true,
14+
defaultTimeoutInterval: 60000
15+
},
16+
};

0 commit comments

Comments
 (0)