我正在尝试让 Jest 再次在 1 年前开发且未维护的项目上工作。
\nsetupFilesAfterEnv我的or路径有错误transform。
当我运行“纱线测试”时出现错误
\n$ jest __testsv2__ --config=./jest.config.js\n\xe2\x97\x8f Validation Error:\n\nModule <rootDir>/jest/setup.js in the setupFilesAfterEnv option was not found.\n <rootDir> is: /Users/alain/dev/ddf/release\n\nConfiguration Documentation:\nhttps://jestjs.io/docs/configuration.html\n\nerror Command failed with exit code 1.\nRun Code Online (Sandbox Code Playgroud)\n我的文件系统,在 /Users/alain/dev/ddf/release/ 我有
\n babel.config.js\n jest.config.js\n /jest\n /setup\n setup.js ( so full path is : /Users/alain/dev/ddf/release/jest/setup.js ) \n staticFileAssetTransform.js ( so full path is : /Users/alain/dev/ddf/release/jest/staticFileAssetTransform.js ) \nRun Code Online (Sandbox Code Playgroud)\n我的package.json
\n{ ...\n "scripts": {\n "test": "jest __testsv2__ --config=./jest.config.js"\n ...\n }\n}\nRun Code Online (Sandbox Code Playgroud)\nbabel.config.js
\nmodule.exports = function(api) {\n api.cache(false);\n const presets = ['@babel/preset-env', '@babel/preset-react']; \n const plugins = [['@babel/proposal-object-rest-spread'],];\n\n return {\n presets, plugins, sourceMaps: "inline",\n ignore: [(process.env.NODE_ENV !== 'test' ? "**/*.test.js" : null) ].filter(n => n)\n };\n };\nRun Code Online (Sandbox Code Playgroud)\n笑话配置.js
\n module.exports = {\n resolver: 'browser-resolve',\n clearMocks: true,\n moduleNameMapper: { '\\\\.(css|less|styl|md)$': 'identity-obj-proxy' },\n // A list of paths to modules that run some code to configure or set up the testing framework before each test\n // setupFilesAfterEnv: ['./jest/setup.js'], // don't work too\n setupFilesAfterEnv: ['<rootDir>/jest/setup.js'], \n\n\n // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped\n testPathIgnorePatterns: ['/node_modules/', '/__gql_mocks__/'],\n\n // A map from regular expressions to paths to transformers\n transform: {\n '^.+\\\\.js$': './jest/babelRootModeUpwardTransform.js',\n '\\\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/jest/staticFileAssetTransform.js',\n },\n};\nRun Code Online (Sandbox Code Playgroud)\n对于来到这里的人,请确保在路径前添加前缀<rootDir>
像这样:
setupFilesAfterEnv: ['<rootDir>/node_modules/@hirez_io/observer-spy/dist/setup-auto-unsubscribe.js']
| 归档时间: |
|
| 查看次数: |
33060 次 |
| 最近记录: |