Giter Site home page Giter Site logo

Comments (10)

mpuittinen avatar mpuittinen commented on June 15, 2024

from serverless-mocha-plugin.

kaiyyyy avatar kaiyyyy commented on June 15, 2024

Hello! Thank you for the response. This was what I did.

  1. install serverless
  2. use serverless to create a service
  3. inside the service, I installed serverless-mocha-plugin locally
  4. 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
  1. 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);

};
  1. I created the test using sls create test --function
  2. I changed nothing in the test and ran the test and this was the output

hello
${opt:region,self:provider.region}
√ implement tests here

1 passing (10ms)

My OS is Windows Server 2016. I appreciate the help you are giving me in this!

from serverless-mocha-plugin.

mpuittinen avatar mpuittinen commented on June 15, 2024

from serverless-mocha-plugin.

kaiyyyy avatar kaiyyyy commented on June 15, 2024

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.

laardee avatar laardee commented on June 15, 2024

@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.

mpuittinen avatar mpuittinen commented on June 15, 2024

@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:

  1. clone the git project
  2. npm install
  3. npm run test

from serverless-mocha-plugin.

laardee avatar laardee commented on June 15, 2024

@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.

laardee avatar laardee commented on June 15, 2024

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.

kaiyyyy avatar kaiyyyy commented on June 15, 2024

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.

kaiyyyy avatar kaiyyyy commented on June 15, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.