Skip to content
This repository was archived by the owner on Oct 28, 2023. It is now read-only.

Commit c0d9416

Browse files
committed
Finished CircleCI setup, tests, coverage & lint #9
- Added required dependencies - Added database setup through environment variables for CI and through hidden.js for local environment - Added extra rules for linting - Added test setup and coverage reports npm run migrate parses hidden.js to extract the password as an environment variable. This is a quick hack to factor out the password from database.json
1 parent 930f876 commit c0d9416

File tree

8 files changed

+5234
-248
lines changed

8 files changed

+5234
-248
lines changed

.circleci/config.yaml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ jobs:
88
docker:
99
# specify the version you desire here
1010
- image: circleci/node:10-browsers
11-
11+
environment:
12+
- MYSQL_PASSWORD: very-secret
13+
1214
- image: circleci/mysql:5.7.23
1315
environment:
1416
- MYSQL_USER: dbuser
1517
- MYSQL_PASSWORD: very-secret
1618

17-
working_directory: ~/repo
19+
working_directory: ~/SOEN343
1820

1921
steps:
2022
- checkout
@@ -24,6 +26,7 @@ jobs:
2426
keys:
2527
- v1-dependencies-{{ checksum "package.json" }}
2628
# fallback to using the latest cache if no exact match is found
29+
- v1-dependencies-
2730

2831
- run: npm install
2932

@@ -34,25 +37,17 @@ jobs:
3437

3538
- run:
3639
name: setup database
37-
command: npm run migrate db:create anansi_db && npm run migrate up
40+
# Create db and run all migrations
41+
command: node_modules/db-migrate/bin/db-migrate db:create anansi_db && node_modules/db-migrate/bin/db-migrate up
3842

3943
- run:
4044
name: test
4145
command: npm test
4246

43-
- run:
44-
name: coverage
45-
command: npm run coverage
46-
4747
- run:
4848
name: lint
4949
command: npm run lint
5050

5151
- store_artifacts: # TODO
52-
path: test-results.xml
53-
prefix: tests
54-
- store_artifacts: # TODO
55-
path: coverage
52+
path: test-report.html
5653
prefix: coverage
57-
- store_test_results: # TODO
58-
path: test-results.xml

.eslintrc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"extends": "standard",
33
"rules": {
44
"semi": [2, "always"],
5-
"indent": ["error", 4]
5+
"indent": ["error", 4],
6+
"no-unused-vars": "warn",
7+
"comma-dangle": "off",
8+
"camelcase": "error"
69
}
710
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
hidden.js
3+
coverage/

config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
var hidden = {};
2+
try {
3+
hidden = require('hidden');
4+
} catch (ex) {}
5+
16
var config = {
27
db: {
3-
host: '127.0.0.1',
8+
host: '127.0.0.1', // localhost
49
user: 'dbuser',
5-
password: 'very-secret',
10+
password: hidden.password || process.env.MYSQL_PASSWORD,
611
db: 'anansi_db'
712
}
813
};

database.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@
44
"driver": "mysql",
55
"host": "localhost",
66
"user": "dbuser",
7-
"password": "very-secret",
8-
"database": "anansi_db"
9-
},
10-
"test": {
11-
"driver": "mysql",
12-
"host": "localhost",
13-
"user": "root",
14-
"password": "",
7+
"password": {"ENV": "MYSQL_PASSWORD"},
158
"database": "anansi_db"
169
}
1710
}

jest.config.js

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
// For a detailed explanation regarding each configuration property, visit:
2+
// https://jestjs.io/docs/en/configuration.html
3+
4+
module.exports = {
5+
// All imported modules in your tests should be mocked automatically
6+
// automock: false,
7+
8+
// Stop running tests after the first failure
9+
// bail: false,
10+
11+
// Respect "browser" field in package.json when resolving modules
12+
// browser: false,
13+
14+
// The directory where Jest should store its cached dependency information
15+
// cacheDirectory: "/tmp/jest_rs",
16+
17+
// Automatically clear mock calls and instances between every test
18+
clearMocks: true,
19+
20+
// Indicates whether the coverage information should be collected while executing the test
21+
// collectCoverage: false,
22+
23+
// An array of glob patterns indicating a set of files for which coverage information should be collected
24+
// collectCoverageFrom: null,
25+
26+
// The directory where Jest should output its coverage files
27+
coverageDirectory: 'coverage',
28+
29+
// An array of regexp pattern strings used to skip coverage collection
30+
// coveragePathIgnorePatterns: [
31+
// "/node_modules/"
32+
// ],
33+
34+
// A list of reporter names that Jest uses when writing coverage reports
35+
coverageReporters: [
36+
'json',
37+
'text',
38+
// "lcov",
39+
// "clover"
40+
],
41+
42+
// An object that configures minimum threshold enforcement for coverage results
43+
// coverageThreshold: null,
44+
45+
// Make calling deprecated APIs throw helpful error messages
46+
// errorOnDeprecated: false,
47+
48+
// Force coverage collection from ignored files usin a array of glob patterns
49+
// forceCoverageMatch: [],
50+
51+
// A path to a module which exports an async function that is triggered once before all test suites
52+
// globalSetup: null,
53+
54+
// A path to a module which exports an async function that is triggered once after all test suites
55+
// globalTeardown: null,
56+
57+
// A set of global variables that need to be available in all test environments
58+
// globals: {},
59+
60+
// An array of directory names to be searched recursively up from the requiring module's location
61+
// moduleDirectories: [
62+
// "node_modules"
63+
// ],
64+
65+
// An array of file extensions your modules use
66+
// moduleFileExtensions: [
67+
// "js",
68+
// "json",
69+
// "jsx",
70+
// "node"
71+
// ],
72+
73+
// A map from regular expressions to module names that allow to stub out resources with a single module
74+
// moduleNameMapper: {},
75+
76+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
77+
// modulePathIgnorePatterns: [],
78+
79+
// Activates notifications for test results
80+
// notify: false,
81+
82+
// An enum that specifies notification mode. Requires { notify: true }
83+
// notifyMode: "always",
84+
85+
// A preset that is used as a base for Jest's configuration
86+
// preset: null,
87+
88+
// Run tests from one or more projects
89+
// projects: null,
90+
91+
// Use this configuration option to add custom reporters to Jest
92+
reporters: [
93+
'default',
94+
['./node_modules/jest-html-reporter', {
95+
pageTitle: 'Test Report'
96+
}]
97+
],
98+
99+
// Automatically reset mock state between every test
100+
// resetMocks: false,
101+
102+
// Reset the module registry before running each individual test
103+
// resetModules: false,
104+
105+
// A path to a custom resolver
106+
// resolver: null,
107+
108+
// Automatically restore mock state between every test
109+
// restoreMocks: false,
110+
111+
// The root directory that Jest should scan for tests and modules within
112+
// rootDir: null,
113+
114+
// A list of paths to directories that Jest should use to search for files in
115+
// roots: [
116+
// "<rootDir>"
117+
// ],
118+
119+
// Allows you to use a custom runner instead of Jest's default test runner
120+
// runner: "jest-runner",
121+
122+
// The paths to modules that run some code to configure or set up the testing environment before each test
123+
// setupFiles: [],
124+
125+
// The path to a module that runs some code to configure or set up the testing framework before each test
126+
// setupTestFrameworkScriptFile: null,
127+
128+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
129+
// snapshotSerializers: [],
130+
131+
// The test environment that will be used for testing
132+
testEnvironment: 'node',
133+
134+
// Options that will be passed to the testEnvironment
135+
// testEnvironmentOptions: {},
136+
137+
// Adds a location field to test results
138+
// testLocationInResults: false,
139+
140+
// The glob patterns Jest uses to detect test files
141+
// testMatch: [
142+
// "**/__tests__/**/*.js?(x)",
143+
// "**/?(*.)+(spec|test).js?(x)"
144+
// ],
145+
146+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
147+
// testPathIgnorePatterns: [
148+
// "/node_modules/"
149+
// ],
150+
151+
// The regexp pattern Jest uses to detect test files
152+
// testRegex: "",
153+
154+
// This option allows the use of a custom results processor
155+
// testResultsProcessor: null,
156+
157+
// This option allows use of a custom test runner
158+
// testRunner: "jasmine2",
159+
160+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
161+
// testURL: "http://localhost",
162+
163+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
164+
// timers: "real",
165+
166+
// A map from regular expressions to paths to transformers
167+
// transform: null,
168+
169+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
170+
// transformIgnorePatterns: [
171+
// "/node_modules/"
172+
// ],
173+
174+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
175+
// unmockedModulePathPatterns: undefined,
176+
177+
// Indicates whether each individual test should be reported during the run
178+
// verbose: null,
179+
180+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
181+
// watchPathIgnorePatterns: [],
182+
183+
// Whether to use watchman for file crawling
184+
// watchman: true,
185+
};

0 commit comments

Comments
 (0)