-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDEV_NOTES.txt
89 lines (63 loc) · 3.52 KB
/
DEV_NOTES.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Basic Test To Validate Environment
-------------------
1. Edit index.js
2. At the end of the file, add a new logging line: logger.info('my test string');
3. Save & Close
4. Edit public/index.html
5. Inside the </body> tag, add a new line: <h1>my ui test string</h1>
6. Save & Close
7. Start Node with the command "node index.js"
8. "my test string" should be immediately logged to the console window
9. Open http://localhost in the browser
10. "my ui test string" should be displayed on the screen
File/Directory Overview
-------------------
index.js - entry point for the application
database/ - database schema and scripts for updating the database schema
public/ - static resources served by node (html, js, css, etc)
routes/ - express endpoints for backend rest api
tests/ - unit tests using mocha/karma
bin/ - executable scripts for managing server processes
docs/ - documentation and evidence
docker/ - Containerization scripts
Development Commands
-------------------
"gulp start" - starts node on index.js while watching the filesystem for changes and restarts node any time there is a javascript file change
"gulp test" - runs the mocha unit tests and prints the results
"gulp test-karma" - runs the karma unit tests and prints the results
"gulp test-protractor" - runs the protractor E2E browser tests
"gulp lint" - runs static code analysis on all of the source code and prints the results
"gulp format --file <PATH TO FILE>" - beautifies the source code file at the given path
"gulp liquibase" - updates the database with the latest liquibase changelogs
Adding a mocha test case
-------------------
Mocha test cases are stored in tests/test.js.
In mocha, test cases are grouped with describe() functions and defined with it() functions. The basic format is as follows:
describe('test grouping', function() {
it('description of test case 1', fuction() {
/* code for test case 1 */
});
it('description of test case 2', fuction() {
/* code for test case 2 */
});
});
See also: http://samwize.com/2014/02/08/a-guide-to-mochas-describe-it-and-setup-hooks/
To add a new test case, edit tests/test.js and define a new testcase with an it() function inside an existing describe() grouping or create a new describe() grouping.
Adding a karma test case
------------------------
Karma test cases are stored in tests/karma-*.js files. Karma uses the mocha unit testing framework so see section above on creating tests.
In addition, Karma provides a mock backend to handle AJAX requests. See the file tests/karma-testController.js for an example.
Add a protractor test case
------------------------
Protractor test cases are stored in tests/protractor-*.js files. Protractor uses Jasmine as its testing framework. The
tests are in the same describe/it pattern described in the above mocha section.
Protractor utilizes the Selemium server and webdriver. The server can be kicked off with the bin/protractor_startup.sh script.
Make changes to the database
------------------------
To make schema and data changes to the database, update or create a new liquibase changelog XML file which can be applied to the database
using the "gulp liquibase" command. See the database/db.changelog-1.0.xml file as an example.
IMPORTANT: For a new changelog to be included in the gulp liquibase task, it must be registered in the database/db.changelog-master.xml file.
Jenkins
------------------------
If the server running jenkins is restarted, pm2 (the node process monitor) will need to be restarted as well. To do that, run the following as the 'jenkins' user:
sudo pm2 start index.js