NextJS plugin issue for Cypress Component Testing (options.rewrites.map is not a function) #16136
-
I think I need a little help on how to use the cypress plugin for nextJS in order to run Components Test (https://docs.cypress.io/guides/component-testing/introduction#Install)
"devDependencies": {
"@cypress/react": "^5.3.4",
"@cypress/webpack-dev-server": "^1.1.4",
"@cypress/webpack-preprocessor": "^5.7.0",
"@testing-library/cypress": "^7.0.6",
"@types/lodash": "^4.14.168",
"@types/node": "^14.14.36",
"@types/react": "^17.0.3",
"cypress": "^7.1.0",
"sass": "^1.32.8",
"typescript": "^4.2.3",
"webpack-dev-server": "^3.11.2"
}
module.exports = (on, config) => {
require('@cypress/react/plugins/next')(on, config)
return config
} Trying to start the test throws a $ yarn cypress open-ct
yarn run v1.22.5
$ /Users/norfeldt/Repos/LoCali/locali-web/node_modules/.bin/cypress open-ct
info - Loaded env from /Users/norfeldt/Repos/LoCali/locali-web/.env.local
Error [TypeError]: options.rewrites.map is not a function
at new BuildManifestPlugin (/Users/norfeldt/Repos/LoCali/locali-web/node_modules/next/build/webpack/plugins/build-manifest-plugin.ts:94:38)
at getBaseWebpackConfig (/Users/norfeldt/Repos/LoCali/locali-web/node_modules/next/build/webpack-config.ts:1133:9)
at getNextWebpackConfig (/Users/norfeldt/Repos/LoCali/locali-web/node_modules/@cypress/react/plugins/next/findNextWebpackConfig.js:9:29)
at findNextWebpackConfig (/Users/norfeldt/Repos/LoCali/locali-web/node_modules/@cypress/react/plugins/next/findNextWebpackConfig.js:36:24)
at Object.handler (/Users/norfeldt/Repos/LoCali/locali-web/node_modules/@cypress/react/plugins/next/index.js:5:27)
TypeError: options.rewrites.map is not a function
at new BuildManifestPlugin (/Users/norfeldt/Repos/LoCali/locali-web/node_modules/next/build/webpack/plugins/build-manifest-plugin.ts:94:38)
at getBaseWebpackConfig (/Users/norfeldt/Repos/LoCali/locali-web/node_modules/next/build/webpack-config.ts:1133:9)
at getNextWebpackConfig (/Users/norfeldt/Repos/LoCali/locali-web/node_modules/@cypress/react/plugins/next/findNextWebpackConfig.js:9:29)
at findNextWebpackConfig (/Users/norfeldt/Repos/LoCali/locali-web/node_modules/@cypress/react/plugins/next/findNextWebpackConfig.js:36:24)
at Object.handler (/Users/norfeldt/Repos/LoCali/locali-web/node_modules/@cypress/react/plugins/next/index.js:5:27) Am I missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 12 replies
-
options.rewrites used to be an array but changed to an object - are you using the latest versions of everything (including next) ? |
Beta Was this translation helpful? Give feedback.
-
Probably needs next>10.1 (error is opposite of #15734 where upgrading nextjs broke component testing) |
Beta Was this translation helpful? Give feedback.
-
I did {
"name": "locali-web",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"test": "jest --watch"
},
"dependencies": {
"@stripe/stripe-js": "^1.13.2",
"class-name": "^0.1.3",
"lodash": "^4.17.21",
"next": "10.1.3",
"next-stripe": "^1.0.0-beta.9",
"react": "17.0.1",
"react-dom": "17.0.1",
"stripe": "^8.142.0",
"swr": "^0.5.5"
},
"devDependencies": {
"@cypress/react": "^5.3.4",
"@cypress/webpack-dev-server": "^1.1.4",
"@cypress/webpack-preprocessor": "^5.7.0",
"@testing-library/cypress": "^7.0.6",
"@testing-library/dom": "^7.30.4",
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^13.1.5",
"@types/jest": "^26.0.22",
"@types/lodash": "^4.14.168",
"@types/node": "^14.14.36",
"@types/react": "^17.0.3",
"babel-jest": "^26.6.3",
"cypress": "^7.1.0",
"html-webpack-plugin": "4",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.6.3",
"jest-extended": "^0.11.5",
"sass": "^1.32.8",
"ts-jest": "^26.5.5",
"typescript": "^4.2.3",
"webpack": "4",
"webpack-dev-server": "^3.11.2"
}
} |
Beta Was this translation helpful? Give feedback.
I did
yarn add -D webpack@4 html-webpack-plugin@4
BTW