Human-Connection/API

[BUG] NODE_ENV=test does not change configuration

Closed this issue · 3 comments

According to the docs, changing NODE_ENV=test should load config/test.json. But it's loading only config/local.json.

Steps to reproduce:

// config/test.json
{
  "seeder": {
    "runOnInit": false,
    "dropDatabase": false
  },
}
// config/local.json
{
  "seeder": {
    "runOnInit": true,
    "dropDatabase": false
  },
}

Open chromium, visit chrome://inspect, open dedicated DevTools for Node, then run
NODE_ENV=test node --inspect server/index.js
from your terminal.

Result of app.get('seeder').runOnInit is true.

I found out, we're using an outdated version of featherjs. Will we migrate to v3 any time soon? Out of curiosity, I updated @feathersjs/feathers and @feathersjs/configuration and the new dependencies have the desired behaviour, ie. overwrite the default config with NODE_ENV.json config.

This bug makes our build unreliable on Travis. It copies local.json from local.example.json which has runOnInit: true and therefore it happily creates contributions and users. I could forestall it by adding a config.json in travis.yml but that feels silly to me.

Yeah we want to upgrade after the following branches merge. Then we have a bit more headroom.

Issue was caused by not using cross-env for setting env variables and also by using process.env.NODE_ENV without the .env. part.