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

Adrián Mouly

05/24/2022, 6:47 PM
Question regarding testing..
sst test
has been removed, right? How should I execute my existing tests? also, should I migrate to Vitest?
t

thdxr

05/24/2022, 7:02 PM
I would definitely suggest migrating to vitest, we just did it for the sst codebase and the speedup is insane
that said you don't need to do this, you can install jest + follow the steps on their site to set it up
all
sst test
really did was run jest for you
a

Adrián Mouly

05/24/2022, 7:53 PM
Ok, going to take a look.
@thdxr is there examples on how to use vitest?
I mean, with SST.
I configured fine, but want to write some test now.
t

thdxr

05/24/2022, 8:02 PM
should be identical to jest only different is you have to
import { test, expect, ..etc} from "vitest"
a

Adrián Mouly

05/24/2022, 8:02 PM
Oh, ok.
Can I set the stage too?
Because I want to set an stage to use, that way can read the env-vars.
t

thdxr

05/24/2022, 8:04 PM
I actually don't write stack tests so I'm not as familiar with how people write tests
but I believe you can when initializing
App
a

Adrián Mouly

05/24/2022, 8:05 PM
Good point.
Ok, I did that but still not reading my env-vars.
So will need to check some examples.
f

Frank

05/24/2022, 11:33 PM
Hey @Adrián Mouly, I added an example for running stacks tests here https://github.com/serverless-stack/serverless-stack/tree/master/examples/stack-tests
It shows how to create an app object in a specific stage (ie. “prod”), and loading environment variables from
.env
files.
Let me know if this makes sense.
a

Adrián Mouly

05/24/2022, 11:39 PM
Cool, going to check it.
l

Lukasz K

05/25/2022, 12:16 PM
Ok, I totally fell in love with
vitest
, thanks for the change team! 😄
a

Adrián Mouly

05/25/2022, 8:05 PM
Thank you very much @Frank, this example worked for me.