Hi everyone! how are you? I've created my first SS...
# help
f
Hi everyone! how are you? I've created my first SST application and I want to create some e2e test on it, is there any guide to do that using the testing framework SST comes with? In the examples there is only asserts of infrastructure right? I want to specifically hit the lambdas with requests and asserts response code/headers/body
f
Hey @Federico Miras, yeah SST uses jest, and it’s mostly intended for unit tests.
As for integration or e2e tests, are you looking to test the deployed API endpoint? Or are you looking to do frontend testing using something like Cypress?
f
Hi Frank, thanks a lot for answering! yes, I'm talking about testing an already deployed API endpoint but I want to make that happen under
sst test
do you think that's possible?
If there is anything done yet we can make it ourselves! I think it would be great to have something like the command
sst test
running all unit, and a special file (maybe
integration.ts
or
e2e.ts
) where we have the following snippet:
Copy code
import { expect, haveResource } from "@aws-cdk/assert";
import * as sst from "@serverless-stack/resources";
import CategorizerApiStack from "../stacks/CategorizerApiStack";

test("End-to-end testing", url => {
  console.log(url) // a specific url of a just deployed stack to perform e2e tests
  // do requests and asserts of status code / response body
});
f
Hey @Federico Miras, sorry for the late follow up. There isn’t an automatical way to get the “just deployed url” in the test. I was actually just talking to @thdxr about this. It’s something we want solve in the short term. I will keep you posted when we have something.
f
Ok Frank, thanks a lot for the update! As soon as there is anything for this I'll write the E2E tests! meanwhile I'm just doing unit testing until then (I couldn't manage the time to R&D our own solution for that)