Comments (8)
Merged fix to master and published version 1.3.2 of the plugin.
from serverless-mocha-plugin.
Perhaps using this https://github.com/serverless/serverless/blob/master/lib/classes/Variables.js#L25 instead of the current would be better?
from serverless-mocha-plugin.
@nwhite89 thanks, I noticed this also couple days ago, I'll start working on this ASAP.
from serverless-mocha-plugin.
👍 that's great @laardee have been waiting to move to use this due to serverless-offline
that's finally working and then came against builds going red and had no clue what was going on lol.
from serverless-mocha-plugin.
I am still having this issue in my project.
The environment variables are coming in fine when I use the following serverless test:
sls invoke local -f getPlaces -p test/event.json
However, when I use the mocha test, I don't get the environment variables.
sls invoke test
my secrets are kept in a file called secrets.dev.yml
in serverless.yml
I have:
custom:
secrets: ${file(secrets.${opt:stage, self:provider.stage}.yml)}
provider:
name: aws
runtime: nodejs4.3
memorySize: 512 # optional, default is 1024
timeout: 10 # optional, default is 6
stage: dev
region: us-east-1
environment:
API_KEY: ${self:custom.secrets.API_KEY}
I am using serverless 1.5.0 and serverless-mocha-plugin 1.3.2
from serverless-mocha-plugin.
@jloveland hi, is this setup something like yours https://github.com/laardee/sls-mocha-env-vars-test?
from serverless-mocha-plugin.
@laardee thanks so much for the example! the problem was that I had the following syntax in my secrets.dev.yml:
API_KEY=secret-api-key
instead of:
API_KEY: secret-api-key
is this a bug since that syntax causes the test to show the env var as undefined
, or is that invalid yaml? curious why it wouldn't fail with sls invoke local
from serverless-mocha-plugin.
@jloveland I've also done same mistake couple times when converting .env files to env.yml 😄 . Does the sls invoke local
pass the environmental variable to the function or does it just fail silently?
from serverless-mocha-plugin.
Related Issues (20)
- Tests duplicates with multiple files HOT 2
- Exit code 0 when tests fail HOT 3
- Support for bdd-lazy-vars
- Remove warning for nodejs10.x runtime
- Is this the end? HOT 1
- sls invoke test -c does not exit. HOT 1
- nyc with this plugin not generate good output HOT 1
- startOffline.sh not working with newer versions of serverless offline HOT 2
- error: node.js 10.x is not supported when running sls create function HOT 2
- Is it planned to release v1.12.0 also on npmjs? HOT 2
- Release support for Node 12 to npm HOT 1
- Post test script fails to run if tests fail
- Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called;
- Error: Cannot find module 'undefined/path/to/functions' HOT 3
- How to run all tests that are in different directories HOT 1
- TypeError: Cannot read property 'handler' of undefined HOT 5
- Support for typescript base projects
- Not working with typescript and serverless v2
- Snyk reports indirect vulnerabilities
- serverless-mocha-plugin plugin does not set types (yet) which will be required in serverless v4.0.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-mocha-plugin.