https://serverless-stack.com/ logo
#help
Title
# help
m

Mike McCall

10/27/2021, 4:59 PM
ts question, I have a file
test/setup.ts
with a
beforeAll
function. When I run
npx sst build
i get this error
Copy code
ReferenceError: beforeAll is not defined
    at Object.<anonymous> (/Users/mike/source/trevco-commerce/test/setup.ts:21:1)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/Users/mike/source/trevco-commerce/.build/run.js:86:17)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
t

thdxr

10/27/2021, 5:05 PM
Do you have
@types/jest
installed?
m

Mike McCall

10/27/2021, 5:05 PM
I do
I think this error is misleading somehow. I just switched to a different branch in the app and it works.
t

thdxr

10/27/2021, 5:11 PM
When running
sst build
if your
test
folder is included in
tsconfig.json
it'll probably try to build it and fail
Is
beforeAll
valid in
setup.ts
?
Thought that had to go in test files
m

Mike McCall

10/27/2021, 5:12 PM
import it into the test files. It works 🤷
I tried to include and exclude the test in tsconfig
false alarm! all good. Auto imports from vscode pulled a module from the setup file. Thanks!