mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
E2e tests: launch Selenium and node server and kill them after finishing the tests, using a test database
This commit is contained in:
parent
69c4977511
commit
431622ce14
5 changed files with 23 additions and 7 deletions
|
|
@ -4,11 +4,7 @@ node_js:
|
|||
services:
|
||||
- mongodb
|
||||
before_script:
|
||||
- 'npm install -g bower grunt-cli'
|
||||
- 'bower install'
|
||||
- 'npm install -g grunt-cli'
|
||||
- export DISPLAY=:99.0
|
||||
- sh -e /etc/init.d/xvfb start
|
||||
- cp config.json.example config.json
|
||||
- ./node_modules/protractor/bin/webdriver-manager update
|
||||
- ./node_modules/protractor/bin/webdriver-manager start > /dev/null &
|
||||
- grunt run:dev > /dev/null &
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
"npm": "1.2.x"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt karma:continuous && ./node_modules/protractor/bin/protractor protractor.conf.js",
|
||||
"test": "./test/run_tests.sh",
|
||||
"start": "grunt run:dev",
|
||||
"postinstall": "./node_modules/bower/bin/bower install -f"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@ exports.config = {
|
|||
showColors: true,
|
||||
defaultTimeoutInterval: 30000
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ describe('front page', function() {
|
|||
it("don't login when using wrong credentials", function(){
|
||||
var button = element(by.className('btn'));
|
||||
button.click();
|
||||
browser.sleep(1000);
|
||||
element(by.model('loginUsername')).sendKeys('username');
|
||||
element(by.model('loginPassword')).sendKeys('pass');
|
||||
var login = element(by.css("#login-tab input[value='Login']"));
|
||||
|
|
|
|||
19
test/run_tests.sh
Executable file
19
test/run_tests.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
# Configuration
|
||||
TEST_DB=habitrpg_test
|
||||
TEST_DB_URI="mongodb://localhost/$TEST_DB"
|
||||
|
||||
# Build assets
|
||||
grunt build:dev
|
||||
|
||||
# Launch Node server and Selenium
|
||||
echo "Recreating test database"
|
||||
mongo "$TEST_DB" --eval "db.dropDatabase()"
|
||||
./node_modules/protractor/bin/webdriver-manager update
|
||||
./node_modules/protractor/bin/webdriver-manager start > /dev/null &
|
||||
NODE_DB_URI="$TEST_DB_URI" node ./src/server.js > /dev/null &
|
||||
NODE_PID=$!
|
||||
trap "kill $NODE_PID && curl http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer" EXIT
|
||||
|
||||
sleep 3 # Wait for Selenium
|
||||
grunt karma:continuous && ./node_modules/protractor/bin/protractor protractor.conf.js
|
||||
Loading…
Reference in a new issue