11// @ts -check
2+ const path = require ( 'path' )
23const debug = require ( 'debug' ) ( 'cypress-react-unit-test' )
34const loadConfig = require ( 'next/dist/next-server/server/config' ) . default
45const getNextJsBaseWebpackConfig = require ( 'next/dist/build/webpack-config' )
@@ -11,19 +12,29 @@ async function getNextWebpackConfig(config) {
1112 config && config . env && config . env . coverage === false
1213
1314 debug ( 'coverage is disabled? %o' , { coverageIsDisabled } )
15+ debug ( 'Cypress project %o' , {
16+ projectRoot : config . projectRoot ,
17+ componentFolder : config . componentFolder ,
18+ } )
1419
1520 const nextConfig = await loadConfig ( 'development' , config . projectRoot )
21+
22+ const configOptions = {
23+ buildId : `cypress-react-unit-test-${ Math . random ( ) . toString ( ) } ` ,
24+ config : nextConfig ,
25+ dev : false ,
26+ isServer : false ,
27+ // assuming the Next.js project has the entire pages in "/pages" subfolder
28+ // https://github.com/bahmutov/cypress-react-unit-test/pull/517
29+ pagesDir : path . join ( config . projectRoot , 'pages' ) ,
30+ entrypoints : { } ,
31+ rewrites : [ ] ,
32+ }
33+ debug ( 'Next config options %o' , configOptions )
34+
1635 const nextWebpackConfig = await getNextJsBaseWebpackConfig (
1736 config . projectRoot ,
18- {
19- buildId : `cypress-react-unit-test-${ Math . random ( ) . toString ( ) } ` ,
20- config : nextConfig ,
21- dev : false ,
22- isServer : false ,
23- pagesDir : config . projectRoot ,
24- entrypoints : { } ,
25- rewrites : [ ] ,
26- } ,
37+ configOptions ,
2738 )
2839
2940 debug ( 'resolved next.js webpack options: %o' , nextWebpackConfig )
0 commit comments