https://serverless-stack.com/ logo
#sst
Title
# sst
a

Adrián Mouly

08/31/2021, 8:15 PM
Anyone having this error? running
sst test
.
@Frank this happens to me with default config from SST.
f

Frank

09/01/2021, 6:16 AM
Hey @Adrián Mouly, you are using yarn workspace, and SST is one of the packages in the workspace right?
a

Adrián Mouly

09/01/2021, 6:19 AM
Yes sir.
And also, using typescript.
f

Frank

09/01/2021, 3:31 PM
@Adrián Mouly I created a gh repo with a similar structure.
The test ran fine for me. Can you see what might be the difference? https://github.com/fwang/sst-triage-ts-jest
a

Adrián Mouly

09/01/2021, 3:41 PM
Hummmmm, ok let me check, thank you for taking the time.
@Frank I’ve checked this but… why your SST is on
serviceA
? shouldn’t be at the root?
So if you have 10 services, you are going to have 10
sst
files?
f

Frank

09/01/2021, 4:34 PM
Sorry I misunderstood what you mean. I thought the SST app is one of the packages.
So the
sst.json
is at the root. Are you also running
sst test
from the foot?
a

Adrián Mouly

09/01/2021, 7:27 PM
@Frank yes sir.
I’m following the monorepo model, I think there is a repo with that.
f

Frank

09/01/2021, 11:32 PM
I just updated the project structure https://github.com/fwang/sst-triage-ts-jest
sst test
should pickup both the infrastructure tests in
test/
and lambda function tests in
packages/serviceA/
a

Adrián Mouly

09/02/2021, 1:02 AM
Thank you sir, going to check it.
Foudn the problem.
Somehow having the
/frontend
app makes that error.
For some reason my frontend project is adding that dependency.
f

Frank

09/02/2021, 3:59 AM
I see. I think it might make sense to exclude the frontend tests from the
npm test
script. Maybe see if setting the scope for the test script helps:
Copy code
"test": "lerna run prepare && lerna run test --stream --scope='{serviceA,serviceB}'"
a

Adrián Mouly

09/02/2021, 4:00 AM
Interesting, didn’t thought about using lerna that way.
Not sure how can include the SST tests too.
Because those doesn’t have scope, right?
f

Frank

09/02/2021, 4:05 AM
hmm.. that’s a good point
a

Adrián Mouly

09/02/2021, 4:06 AM
Interesting.
Maybe we need to define a workspace for SST code?
Or that is not a good idea?
f

Frank

09/02/2021, 4:07 AM
I’m thinking about that too. Maybe give it a try.
a

Adrián Mouly

09/02/2021, 4:08 AM
Today I have
lib
and
test
on the root.
f

Frank

09/02/2021, 4:08 AM
Let me cc @thdxr on this.. he’s given some thoughts on the project structure side of things
Yeah, I wonder if it makes sense to move test inside lib?
a

Adrián Mouly

09/02/2021, 4:08 AM
Yeah he has different thoughts about folder structure, I been trying to find the right way.
Yeah possibly, inside
lib
would make more sense.
Can’t find which should be the correct structure.
Because I have
frontend
,
src
,
lib
and
test
on the root.
But this doesn’t make much sense.
frontend
also has
src
inside.
Maybe I have to create 3 main folders with children:
Copy code
- frontend
  - src
  - test
- backend
  - src
  - test
- infrastructure
  - src
  - test
I wonder how much stuff I’m going to break from SST-CLI if I do this, hahaha.
Is there a way to tell
sst cli
where to look for
index.ts
?
Ah, found it!
Copy code
"main": "sst/index.ts"
Thanks to @thdxr who created that starter project.
t

thdxr

09/02/2021, 4:42 AM
Starter isn't done yet haha I'm still changing my mind on decisions in it
a

Adrián Mouly

09/02/2021, 4:42 AM
Hahaa.
I know.
Can’t figure out the proper way.
I’m testing this model now:
Copy code
- frontend
  - src
  - test
- backend
  - src
    - packages
      - pkg1
      - pkg2
    - services
      - srv1
      - srv2
  - test
- infrastructure
  - src
  - test
Also @thdxr didn’t use lerna 😞