1
1
// @ts -check
2
+ const path = require ( 'path' )
2
3
const debug = require ( 'debug' ) ( 'cypress-react-unit-test' )
3
4
const loadConfig = require ( 'next/dist/next-server/server/config' ) . default
4
5
const getNextJsBaseWebpackConfig = require ( 'next/dist/build/webpack-config' )
@@ -11,19 +12,29 @@ async function getNextWebpackConfig(config) {
11
12
config && config . env && config . env . coverage === false
12
13
13
14
debug ( 'coverage is disabled? %o' , { coverageIsDisabled } )
15
+ debug ( 'Cypress project %o' , {
16
+ projectRoot : config . projectRoot ,
17
+ componentFolder : config . componentFolder ,
18
+ } )
14
19
15
20
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
+
16
35
const nextWebpackConfig = await getNextJsBaseWebpackConfig (
17
36
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 ,
27
38
)
28
39
29
40
debug ( 'resolved next.js webpack options: %o' , nextWebpackConfig )
0 commit comments