Hello. Any tips for speeding up `sst test` ?  It’...
# help
s
Hello. Any tips for speeding up 
sst test
 ?  It’s is taking upwards of 15 seconds with about 15 simple test cases.
t
sst test
is just calling into jest. I have noticed jest is extremely slow to start up, can you verify if each test is slow or if the startup is slow
s
I noticed that too. 24 second runtime here
the test itself took 9.5 secs 😮
if I run it again, the whole thing takes 11 seconds, with Jest taking just a few seconds. very strange
@Sam N what if you run
yarn test --watch
? does rerunning the tests take a long time when you modify your code?
s
It looks like the type checker is the bottleneck
I noticed that your screenshot does not include a
Running type checker
line after
Linting source
.
t
In your
tsconfig
what do you have under
include
If you're type checking your whole project it's going to be slow
s
lib
and
src
t
Ah yeah that's probably why it's slow. We should probably be recommending a multi-package setup by default
I only have my code folder in the include there and have a seperate package from my application code, then the type checking is only done on sst code
s
There are only 9 files in src at this point
And lib is just index.ts and 2 stacks.
Are you not using ts for your application?
t
I'm a heavy ts user
But I keep boundaries between my code so only what's strictly needed to be typechecked is checked
I'm going to put together a starter for a typescript project that addresses issues like this and will share this week
s
@thdxr speaking of which, I wound up simplifying my multi-workspace setup even more. now I just have one workspace, which is
src
. so that way, the root package.json is nothing but SST/CDK dependencies, and
src/package.json
has everything related to the code
I like this a lot better than anything else I’ve tried
t
Yeah like I said there's very little benefit to having a lot of subpackages. Simplifying all to 1 makes sense. The only reason I have 2 is to create a more explicit boundary between core vs services but it's pretty minor
o
@thdxr bit confused, these seem contradictory?
Ah yeah that’s probably why it’s slow. We should probably be recommending a multi-package setup by default
Yeah like I said there’s very little benefit to having a lot of subpackages.
Wouldn’t the benefit be faster jest runs? Or did I get the wrong end of the stick here?
About to start switching to SST, wondering how to set things up - for multi-package would I have a tsconfig per package that only includes the current package?
t
Haha it is a bit contradictory. We should separate the cdk build from the rest of the codebase instead of including them together. But going crazy with a lot of sub packages has a lot of overhead
Yes you should have a separate tsconfig per package if you're really using separate packages
I started working on this today to write up some of my thoughts around this with an example https://github.com/serverless-stack/typescript-starter