{"action":"created","issue":{"url":"https://api.github.com/repos/SC5/serverless-mocha-plugin/issues/37","repository_url":"https://api.github.com/repos/SC5/serverless-mocha-plugin","labels_url":"https://api.github.com/repos/SC5/serverless-mocha-plugin/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/SC5/serverless-mocha-plugin/issues/37/comments","events_url":"https://api.github.com/repos/SC5/serverless-mocha-plugin/issues/37/events","html_url":"https://github.com/SC5/serverless-mocha-plugin/issues/37","id":196378157,"number":37,"title":"Environment variables loaded from file","user":{"login":"nwhite89","id":1407863,"avatar_url":"https://avatars.githubusercontent.com/u/1407863?v=3","gravatar_id":"","url":"https://api.github.com/users/nwhite89","html_url":"https://github.com/nwhite89","followers_url":"https://api.github.com/users/nwhite89/followers","following_url":"https://api.github.com/users/nwhite89/following{/other_user}","gists_url":"https://api.github.com/users/nwhite89/gists{/gist_id}","starred_url":"https://api.github.com/users/nwhite89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nwhite89/subscriptions","organizations_url":"https://api.github.com/users/nwhite89/orgs","repos_url":"https://api.github.com/users/nwhite89/repos","events_url":"https://api.github.com/users/nwhite89/events{/privacy}","received_events_url":"https://api.github.com/users/nwhite89/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"laardee","id":4726921,"avatar_url":"https://avatars.githubusercontent.com/u/4726921?v=3","gravatar_id":"","url":"https://api.github.com/users/laardee","html_url":"https://github.com/laardee","followers_url":"https://api.github.com/users/laardee/followers","following_url":"https://api.github.com/users/laardee/following{/other_user}","gists_url":"https://api.github.com/users/laardee/gists{/gist_id}","starred_url":"https://api.github.com/users/laardee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laardee/subscriptions","organizations_url":"https://api.github.com/users/laardee/orgs","repos_url":"https://api.github.com/users/laardee/repos","events_url":"https://api.github.com/users/laardee/events{/privacy}","received_events_url":"https://api.github.com/users/laardee/received_events","type":"User","site_admin":false},"assignees":[{"login":"laardee","id":4726921,"avatar_url":"https://avatars.githubusercontent.com/u/4726921?v=3","gravatar_id":"","url":"https://api.github.com/users/laardee","html_url":"https://github.com/laardee","followers_url":"https://api.github.com/users/laardee/followers","following_url":"https://api.github.com/users/laardee/following{/other_user}","gists_url":"https://api.github.com/users/laardee/gists{/gist_id}","starred_url":"https://api.github.com/users/laardee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laardee/subscriptions","organizations_url":"https://api.github.com/users/laardee/orgs","repos_url":"https://api.github.com/users/laardee/repos","events_url":"https://api.github.com/users/laardee/events{/privacy}","received_events_url":"https://api.github.com/users/laardee/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2016-12-19T10:23:14Z","updated_at":"2017-01-07T18:51:29Z","closed_at":"2016-12-21T09:03:58Z","body":"Looks like there is a bug with the way that environment variables are loaded I'm not sure if it's because tests are run to early. But `serverless` allows for loading Env vars from a variable https://serverless.com/blog/serverless-v1.2.0/?utm_source=Newsletter&utm_medium=Email&utm_campaign=v1.2%20release. Such as\r\n\r\n```yml\r\nfunctions:\r\n  myFunction:\r\n    environment:\r\n      apiKey: ${file(../keys.yml):apiKey}\r\n```\r\n\r\nIt looks like that when a test is being run it's still being provided `${file(../keys.yml):apiKey}` rather than the variable itself."},"comment":{"url":"https://api.github.com/repos/SC5/serverless-mocha-plugin/issues/comments/271102237","html_url":"https://github.com/SC5/serverless-mocha-plugin/issues/37#issuecomment-271102237","issue_url":"https://api.github.com/repos/SC5/serverless-mocha-plugin/issues/37","id":271102237,"user":{"login":"jloveland","id":3456708,"avatar_url":"https://avatars.githubusercontent.com/u/3456708?v=3","gravatar_id":"","url":"https://api.github.com/users/jloveland","html_url":"https://github.com/jloveland","followers_url":"https://api.github.com/users/jloveland/followers","following_url":"https://api.github.com/users/jloveland/following{/other_user}","gists_url":"https://api.github.com/users/jloveland/gists{/gist_id}","starred_url":"https://api.github.com/users/jloveland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jloveland/subscriptions","organizations_url":"https://api.github.com/users/jloveland/orgs","repos_url":"https://api.github.com/users/jloveland/repos","events_url":"https://api.github.com/users/jloveland/events{/privacy}","received_events_url":"https://api.github.com/users/jloveland/received_events","type":"User","site_admin":false},"created_at":"2017-01-07T18:51:29Z","updated_at":"2017-01-07T18:51:29Z","body":"I am still having this issue in my project.\r\n\r\nThe environment variables are coming in fine when I use the following serverless test:\r\n`sls invoke local -f getPlaces -p test/event.json`\r\n\r\nHowever, when I use the mocha test, I don't get the environment variables.\r\n`sls invoke test`\r\n\r\nmy secrets are kept in a file called `secrets.dev.yml`\r\n\r\nin `serverless.yml` I have:\r\n```\r\ncustom:\r\n  secrets: ${file(secrets.${opt:stage, self:provider.stage}.yml)}\r\n\r\nprovider:\r\n  name: aws\r\n  runtime: nodejs4.3\r\n  memorySize: 512 # optional, default is 1024\r\n  timeout: 10 # optional, default is 6\r\n  stage: dev\r\n  region: us-east-1\r\n  environment:\r\n    API_KEY: ${self:custom.secrets.API_KEY}\r\n```\r\nI am using serverless 1.5.0 and serverless-mocha-plugin 1.3.2"}}
{"actor":{"display_login":"jloveland"}}