我在为 Snowpack 项目设置 Jest 和 React 测试库时遇到问题,想知道你们中是否有人遇到过类似的情况。所以我收到的错误是The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'指向 。const { SNOWPACK_PUBLIC_BASE_URL } = import.meta.env;我已按照所有文档正确设置配置,但仍然收到此错误。我的配置文件如下。
package.json:
{
"jest": {
"verbose": true,
"preset": "ts-jest",
"testEnvironment": "node",
"transform": {
"node_modules/variables/.+\\.(j|t)sx?$": "ts-jest"
},
"transformIgnorePatterns": [
"node_modules/(?!variables/.*)"
],
"moduleNameMapper": {
"@app/(.*)": "<rootDir>/src/$1",
"@auth/(.*)": "<rootDir>/src/auth/$1",
"@hooks/(.*)": "<rootDir>/src/hooks/$1",
"@gtm/(.*)": "<rootDir>/src/gtm/$1"
}
},
"scripts": {
"start": "snowpack dev",
"build": "snowpack build",
"test": "jest __tests__/ --coverage",
"test:watch": "jest --watch",
"format": "prettier --write …Run Code Online (Sandbox Code Playgroud)