Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore tests in lambda folder #99

Closed
davesag opened this issue Jan 7, 2019 · 6 comments
Closed

Ignore tests in lambda folder #99

davesag opened this issue Jan 7, 2019 · 6 comments
Labels

Comments

@davesag
Copy link

davesag commented Jan 7, 2019

I'm just setting my lambda functions and have the following directory structure

src/
  lambda/
    hello.js
    hello.test.js

Which follows how the rest of the app gets tested.

Unfortunately this means running netlify-lambda build src/lambda results in my tests also being built and installed as if they are lambda functions.

Is there a way to exclude all *.test.js or *.spec.js files?

@davesag
Copy link
Author

davesag commented Jan 7, 2019

for now I work around this by simply adding this script in package.json

"lambda:build": "netlify-lambda build src/lambda",
"postlambda:build": "rm lambda/*.test.js",

but it would be nicer to exclude them during the lambda:build step.

@8eecf0d2
Copy link
Contributor

8eecf0d2 commented Jan 7, 2019

Somewhat unrelated but since you're using Webpack it might be helpful.. I stumbled upon this issue a while back and a couple days ago I added a way to resolve it within 8eecf0d2/netlify-local by allowing users to specify a files array which can be used to compose a Webpack Configuration entry property.

The bundle command docs probably give the best description of how it works, it also flattens nested handlers by replacing forward slashes with dashes (eg, "lambda/nested/handler.js" => "lambda-nested-handler.js").

You can use the logic programatically like so:

const netlifyLocal = require("netlify-local");
const netlifyConfig = netlifyLocal.parseNetlifyConfig("netlify.toml");

module.exports = {
  entry: netlifyLocal.composeWebpackEntry(netlifyConfig),
  ...
}

@8eecf0d2
Copy link
Contributor

8eecf0d2 commented Jan 7, 2019

As far as the issue itself goes, it's a bit of a pain this is the same behaviour as production - to request changes in the production environment you'll need to talk to Netlify Support.

@sw-yx is there a specific / technical support link I should be promoting?

@8eecf0d2 8eecf0d2 added the triage label Jan 7, 2019
@swyxio
Copy link
Contributor

swyxio commented Jan 10, 2019

@8eecf0d2 that is -the- canonical netlify support link, you got it :)

@swyxio
Copy link
Contributor

swyxio commented Jan 10, 2019

hey @davesag , the really really easy way to do this is just dont put the lambda folder in src :) you can put it in a foobar folder if you like. just change your netlify serve _____ and netlify build _____ command accordingly

in fact i really dislike encouraging people to colocate lambda functions and client code. causes potential confusion. problem is we've been recommending it for a while.

riddla pushed a commit to riddla/netlify-lambda that referenced this issue Jan 21, 2019
@swyxio
Copy link
Contributor

swyxio commented Jan 21, 2019

https://github.com/netlify/netlify-lambda/releases/tag/v1.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants