Web Client Test Coverage:
To build the front-end project you'll need to install the following.
Provision and start the vagrant environment.
$ vagrant up
Connect to the running virtual machine.
$ vagrant ssh
All the commands below will be executed from the context of the machine.
Get database dump from someone and copy it into the project root.
vagrant> fab local importdb --set db_dump=[dumpfile_name]
vagrant> python manage.py migrate
Connect to the machine and start the back-end server:
vagrant> cd /vagrant && python manage.py runserver 0.0.0.0:8000
Go to 127.0.0.1:8080
to check if everyting works fine and disconnect from the
vagrant machine.
Make yourself config file(touch mysite/settings/[yourname].py
) and add it to
.gitignore
. Add the following lines to your config file:
from .local import *
# Load JavaScript bundle from the webpack dev server.
STATIC_URL = 'http://127.0.0.1:8090/static/'
# Use one database for all your branches. If you have plans to change the
# database schema, you may want to remove this.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'dfs_master',
#'USER': 'vagrant', # by not specifying a user at all, it will not prompt for password
#'HOST': 'localhost', # default to localhost
#'CONN_MAX_AGE': 60,
}
}
We will use that file later.
Install and activate the node version the project uses (dictated by the .nvrmc file)
$ nvm install
$ nvm use
NOTE: If nvm install fails due to a print statement error, then it's a python3/python2 issue. Try running nvm install
outside the virtualenv where python 2.7 is the default.
Install local project dependencies. Note that you have to explicitly associate python 2.7 due to gyp, used by node-sass.
$ npm install --python=PATH_TO_PYTHON2.7
- Run
npm run devserver
to begin using webpack and generating all necessary frontend files. - Start the back-end server with your configuration:
# Make sure vagrant machine is running
$ vagrant up
# Connect to the machine
$ vagrant ssh
# Start server
$ cd /vagrant && python manage.py runserver 0.0.0.0:8000 --settings='mysite.settings.[name]'
In the package.json file, you'll see our npm tasks under the "scripts" key. These are what we'll use to run Webpack's devserver, test, and build the app.
List all available commands:
$ npm run
Run the tasks with npm's run command:
$ npm run <task name>
We're using Mocha, the testing options are defined in /static/src/js/test/mocha.opts
To run the tests:
$ npm run test