Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 犯错误下一个-test@0.1.0build:`next build`JEST和next.js_Webpack_Jestjs_Next.js_Config - Fatal编程技术网

Webpack 犯错误下一个-test@0.1.0build:`next build`JEST和next.js

Webpack 犯错误下一个-test@0.1.0build:`next build`JEST和next.js,webpack,jestjs,next.js,config,Webpack,Jestjs,Next.js,Config,自从我将jest和react测试库添加到我的项目中以来,我似乎能够将Next.js项目部署到Vercel。如果有人能帮忙,那就太好了 不用于配置,因此不确定要做什么。我在网上浏览了一下,但似乎没有一个对我有用的答案 我的错误: 16:48:25.726 > Build error occurred 16:48:25.728 ReferenceError: expect is not defined 16:48:25.728 at Object.<anonym

自从我将jest和react测试库添加到我的项目中以来,我似乎能够将Next.js项目部署到Vercel。如果有人能帮忙,那就太好了

不用于配置,因此不确定要做什么。我在网上浏览了一下,但似乎没有一个对我有用的答案

我的错误:

16:48:25.726    > Build error occurred
16:48:25.728    ReferenceError: expect is not defined
16:48:25.728        at Object.<anonymous> (/vercel/workpath0/node_modules/@testing-library/jest-dom/dist/extend-expect.js:7:1)
16:48:25.728        at Module._compile (internal/modules/cjs/loader.js:1063:30)
16:48:25.728        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
16:48:25.728        at Module.load (internal/modules/cjs/loader.js:928:32)
16:48:25.728        at Function.Module._load (internal/modules/cjs/loader.js:769:14)
16:48:25.728        at Module.require (internal/modules/cjs/loader.js:952:19)
16:48:25.728        at require (internal/modules/cjs/helpers.js:88:18)
16:48:25.728        at Object.<anonymous> (/vercel/workpath0/node_modules/@testing-library/jest-dom/dist/index.js:3:1)
16:48:25.728        at Module._compile (internal/modules/cjs/loader.js:1063:30)
16:48:25.729        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) {
16:48:25.729      type: 'ReferenceError'
16:48:25.729    }
16:48:25.746    npm ERR! code ELIFECYCLE
16:48:25.746    npm ERR! errno 1
16:48:25.749    npm ERR! next-test@0.1.0 build: `next build`
16:48:25.749    npm ERR! Exit status 1
16:48:25.749    npm ERR! 
16:48:25.749    npm ERR! Failed at the next-test@0.1.0 build script.
16:48:25.749    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
16:48:25.756    npm ERR! A complete log of this run can be found in:
16:48:25.756    npm ERR!     /vercel/.npm/_logs/2021-04-25T15_48_25_750Z-debug.log
16:48:25.760    Error: Command "npm run build" exited with 1
16:48:28.418    Done with "package.json"

这意味着测试是在生产中加载的,这不应该发生。确保
页面中没有针对初学者的测试。@EstusFlask谢谢!忘了把它们取下来!
{
  "name": "next-test",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "test": "jest"
  },
  "dependencies": {
    "@lottiefiles/react-lottie-player": "^3.1.2",
    "next": "10.1.3",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-mailchimp-subscribe": "^2.1.3"
  },
  "devDependencies": {
    "@testing-library/jest-dom": "^5.12.0",
    "@testing-library/react": "^11.2.6",
    "babel-jest": "^26.6.3",
    "identity-obj-proxy": "^3.0.0",
    "jest": "^26.6.3"
  },
  "jest": {
    "moduleNameMapper": {
      "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
      "\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
    }
  }
}
module.exports = {
  webpack(config) {
    config.node = { fs: "empty" };
    return config;
  },
};