serverless-bundle icon indicating copy to clipboard operation
serverless-bundle copied to clipboard

Jest not using the same configuration as build/run

Open confusingbits opened this issue 3 years ago • 2 comments

I'm getting strange error with a monorepo setup.

Folder structure follows sls recommendations.

package.json
lib
  lib1.mjs
services
  service1
    package.json
    index.js
    index.text.js
  service2
    package.json
    index.js
    index.text.js

I can package and run offline just fine. But when I run my tests. I get syntax errors about modules.

Screen Shot 2022-08-17 at 9 39 16 AM

Clearly this is incorrect. I've tried using import or require syntax. Changing extensions to mjs or setting "type": "module" in the project or service package.json. (Jest no longers finds the test if the extension is .mjs.)

confusingbits avatar Aug 17 '22 14:08 confusingbits

@confusingbits same here, Did you resolve that?

vinhjs avatar Dec 27 '23 07:12 vinhjs

@confusingbits

same here, Did you resolve that?

I did. I don't really recall a firm solution. It was some combination of code import changes, file extension changes and package module config. And I think node version?

confusingbits avatar Dec 30 '23 14:12 confusingbits