Comments (10)
from serverless-mocha-plugin.
Hello! Thank you for the response. This was what I did.
- install serverless
- use serverless to create a service
- inside the service, I installed serverless-mocha-plugin locally
- This is what I have inside the serverless.yml
> service: errorProducer
>
> custom:
> region : ${opt:region,self:provider.region}
>
> plugins:
> - serverless-mocha-plugin
>
> provider:
> name: aws
> runtime: nodejs6.10
> stage: dev #stage
> memorySize: 128
> region: 'ap-northeast-1'
> timeout: 10
>
> environment:
> region: ${opt:region,self:provider.region}
>
> functions:
> hello:
> handler: handler.hello
- I used the default handler function and this was what I did inside the handler
'use strict';
var region = process.env.region;
module.exports.hello = (event, context, callback) => {
console.log(region);
callback(null, region);
};
- I created the test using sls create test --function
- I changed nothing in the test and ran the test and this was the output
hello
${opt:region,self:provider.region}
√ implement tests here1 passing (10ms)
My OS is Windows Server 2016. I appreciate the help you are giving me in this!
from serverless-mocha-plugin.
from serverless-mocha-plugin.
Hello!
Thanks for the reply.
I ran the test by running .\node_modules.bin\serverless invoke test
Thanks for looking into this!
Edit: Just to add on, the parsing works perfectly fine (meaning the region correctly output instead of the ${} reference) when it is deployed
Edit: Edit: I have tried reversing the version of "serverless" (not the mocha plugin) to ver 1.8.0 (was using 1.14.0 )and it works fine
from serverless-mocha-plugin.
@kaiyyyy thanks for reporting and especially the Edit: Edit: I have tried reversing the version of "serverless" (not the mocha plugin) to ver 1.8.0 (was using 1.14.0 )and it works fine
part is useful. @mpuittinen I think the issue is related to this nordcloud/serverless-jest-plugin#5. This https://github.com/SC5/serverless-mocha-plugin/blob/master/index.js#L139 part might be the issue here also. Now that I think, the backward compatibility of the jest plugin broke with my last PR. ..
from serverless-mocha-plugin.
@kaiyyyy @laardee I've added tests for the env vars into the module tests and they are currently passing with both 1.14 and 1.15. Still need to investigate.
@kaiyyy can you try the following in your env:
- clone the git project
- npm install
- npm run test
from serverless-mocha-plugin.
@mpuittinen integration tests use serverless 1.7.0 defined in the package.json (Travis don't have serverless installed by default 😁). If you change that and install dependencies again, I'm pretty sure that tests will fail.
from serverless-mocha-plugin.
I added another test that will fail if env vars are not correct (didn't change the sls version in the package.json yet). We need to figure out how to handle backward compatibility though...
from serverless-mocha-plugin.
Apologies for the late reply as I am only able to access the development environment during weekdays.
I have done the 3 steps and I have the following (i believe you are interested in this part? the whole thing is long)
√ tests setEnv with testFunction1 (env vars) √ tests setEnv with testFunction1 √ tests setEnv with testFunction2
from serverless-mocha-plugin.
@laardee @mpuittinen @martinheidegger
Hello!
I have just tested the latest updated version after the merge and now it works perfectly with serverless 1.16.1!
Thanks a lot for the help! I will close this issue later this day
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.