Unit Tests in Serverless

Is the path to the file wrong in this case?

1 Like

As a quick note, the book says:

“SST comes with built in support for writing and running tests. It uses Jest internally for this.”

However, the code sample is actually using Vitest, not Jest.

Fixed! We moved away from Jest.

Hi, I think the guide is misusing the typical naming convention for the “actual” and “expected” values.

Instead of this

const cost = 4000;
const expectedCost = calculateCost(storage);

It should be this

const expectedCost = 4000;
const actualCost = calculateCost(storage);
// OR just `cost`
// const cost = calculateCost(storage);


Does the callback function for your test function need to be ‘async’? As in:

test("Test StorageStack", async () => {
...
});