Support Forums

Spec files getting bundled into functions

We are building a fairly simple app that is a lambda function and a spec file. Our project layout is:

-- verify.ts
-- verify.spec.ts

Whenever we push and the build happens we get the following build error:

9:55:44 AM: ────────────────────────────────────────────────────────────────
9:55:44 AM:   1. Functions bundling                                         
9:55:44 AM: ────────────────────────────────────────────────────────────────
9:55:44 AM: ​
9:55:45 AM: Packaging Functions from functions directory:
9:55:45 AM:  - verify.spec.ts
9:55:45 AM:  - verify.ts
9:55:45 AM: ​

Looking at this issue fix(build): Exclude test files by riddla · Pull Request #105 · netlify/netlify-lambda · GitHub it seems like it should be resolved. However, whenever we push our site we se the above error where it is attempting to package the TypeScript function.

Looks like the issue is in the zip-it-and-ship-it package: Feature Request: Ability to ignore test files for functions · Issue #550 · netlify/zip-it-and-ship-it · GitHub

For now the easiest solution is to move specs to their own independent folder.

1 Like