Jest+React Testing Library config for snowPack #3816
Unanswered
naylinnpkv
asked this question in
Q&A
Replies: 1 comment
-
jest wont understand import.meta, try this
// file: src/helpers/env
export const envVars: EnvRecord = {
YOUR_SECRET: "091742e9-7dba-4ef4-9928-1e39142c86b0",
}
const mockEnvVars: EnvRecord = {
YOUR_SECRET: "mocked YOUR_SECRET",
};
jest.mock("src/helpers/env", () => ({
envVars: mockEnvVars,
})); your actual code then does this to access secrets import { envVars } from "src/helpers/env"
console.log(envVars.YOUR_SECRET) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone, I am having trouble setting up the Jest and React Testing Library for the snowpack project and wondering if any of you have encountered something similar. So the error I am getting is
The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'
which is pointing toconst { SNOWPACK_PUBLIC_BIXBY2_BASE_URL } = import.meta.env;
. My Config files are as follows.package.json:
tsconfig.json:
snowpack.config.js:
.babelrc:
Beta Was this translation helpful? Give feedback.
All reactions