Open HHDog opened 8 years ago
Did you create the proper environment config file using the example file found under /config/environments/example.js
?
All test files run node under test
hence you need a file called /config/environments/test.js
same goes if you run your app in development
mode. By default the application will run in development mode.
This way you can have multiple app instances running in different environments, like development
and test
:
Example:
// `/config/environments/development.js
'use strict';
module.exports = {
port: 3000,
hostname: '127.0.0.1',
baseUrl: 'http://localhost:3000',
mongodb: {
uri: 'mongodb://localhost/cmanager_dev_db'
},
app: {
name: 'Contact manager'
},
serveStatic: true,
session: {
type: 'mongo',
secret: 'your_dev_secret_here',
resave: false,
saveUninitialized: true
}
};
// `/config/environments/test.js
'use strict';
module.exports = {
port: 3030,
hostname: '127.0.0.1',
baseUrl: 'http://localhost:3030',
mongodb: {
uri: 'mongodb://localhost/cmanager_test_db'
},
app: {
name: 'Contact manager'
},
serveStatic: true,
session: {
type: 'mongo',
secret: 'your_test_secret_here',
resave: false,
saveUninitialized: true
}
};
Can you please point out where in the book you point out that this is necessary to do? I seem to have missed it.
@Kachilero There is a section called "The first application file", page 4. This part describes how to create a development
configuration file, also going through the next sections and the most explanatory part can be found on page 8, where it is explained how the system will load the necessary environment configuration file based on the process NODE_ENV
variable. There is also a simple example to run the application in production
using the following cmd:
$ NODE_ENV=production node server.js
Using the preceding cmd, if you have a <project_folder/config/environments/production.js
it will use that file as a configuration for you server.
Feel free to add issues to each repo, as it is an open source project and it will grow in time.
I managed to dream up some fixtures, create a fixtures folder, place them there and re-run the mocha tests. Doing so gives the following error: $ mocha tests/integration/contact_test.js
Contacts endpoints test 1) "before all" hook 2) "after all" hook
0 passing (11ms) 2 failing
1) Contacts endpoints test "before all" hook: TypeError: Cannot read property 'port' of undefined at Context. (tests/integration/contact_test.js:52:28)
2) Contacts endpoints test "after all" hook: TypeError: Cannot read property 'connection' of undefined at Context. (tests/integration/contact_test.js:60:13)