@@ -40,6 +40,13 @@ const context = {}
40
40
describe ( 'Production Usage' , ( ) => {
41
41
let output = ''
42
42
beforeAll ( async ( ) => {
43
+ if ( process . env . NEXT_PRIVATE_TEST_WEBPACK4_MODE ) {
44
+ await fs . rename (
45
+ join ( appDir , 'pages/static-image.js' ) ,
46
+ join ( appDir , 'pages/static-image.js.bak' )
47
+ )
48
+ }
49
+
43
50
const result = await runNextCommand ( [ 'build' , appDir ] , {
44
51
stderr : true ,
45
52
stdout : true ,
@@ -60,31 +67,44 @@ describe('Production Usage', () => {
60
67
server = await startApp ( app )
61
68
context . appPort = appPort = server . address ( ) . port
62
69
} )
63
- afterAll ( ( ) => stopApp ( server ) )
70
+ afterAll ( async ( ) => {
71
+ if ( process . env . NEXT_PRIVATE_TEST_WEBPACK4_MODE ) {
72
+ await fs . rename (
73
+ join ( appDir , 'pages/static-image.js.bak' ) ,
74
+ join ( appDir , 'pages/static-image.js' )
75
+ )
76
+ }
77
+ await stopApp ( server )
78
+ } )
64
79
65
80
it ( 'should contain generated page count in output' , async ( ) => {
66
- expect ( output ) . toContain ( 'Generating static pages (0/38)' )
67
- expect ( output ) . toContain ( 'Generating static pages (38/38)' )
81
+ const pageCount = process . env . NEXT_PRIVATE_TEST_WEBPACK4_MODE ? 37 : 38
82
+ expect ( output ) . toContain ( `Generating static pages (0/${ pageCount } )` )
83
+ expect ( output ) . toContain (
84
+ `Generating static pages (${ pageCount } /${ pageCount } )`
85
+ )
68
86
// we should only have 4 segments and the initial message logged out
69
87
expect ( output . match ( / G e n e r a t i n g s t a t i c p a g e s / g) . length ) . toBe ( 5 )
70
88
} )
71
89
72
- it ( 'should not contain currentScript usage for publicPath' , async ( ) => {
73
- const globResult = await glob ( 'webpack-*.js' , {
74
- cwd : join ( appDir , '.next/static/chunks' ) ,
75
- } )
90
+ if ( ! process . env . NEXT_PRIVATE_TEST_WEBPACK4_MODE ) {
91
+ it ( 'should not contain currentScript usage for publicPath' , async ( ) => {
92
+ const globResult = await glob ( 'webpack-*.js' , {
93
+ cwd : join ( appDir , '.next/static/chunks' ) ,
94
+ } )
76
95
77
- if ( ! globResult || globResult . length !== 1 ) {
78
- throw new Error ( 'could not find webpack-hash.js chunk' )
79
- }
96
+ if ( ! globResult || globResult . length !== 1 ) {
97
+ throw new Error ( 'could not find webpack-hash.js chunk' )
98
+ }
80
99
81
- const content = await fs . readFile (
82
- join ( appDir , '.next/static/chunks' , globResult [ 0 ] ) ,
83
- 'utf8'
84
- )
100
+ const content = await fs . readFile (
101
+ join ( appDir , '.next/static/chunks' , globResult [ 0 ] ) ,
102
+ 'utf8'
103
+ )
85
104
86
- expect ( content ) . not . toContain ( '.currentScript' )
87
- } )
105
+ expect ( content ) . not . toContain ( '.currentScript' )
106
+ } )
107
+ }
88
108
89
109
describe ( 'With basic usage' , ( ) => {
90
110
it ( 'should render the page' , async ( ) => {
@@ -917,54 +937,56 @@ describe('Production Usage', () => {
917
937
expect ( await browser . eval ( 'window.location.pathname' ) ) . toBe ( '/non-existent' )
918
938
} )
919
939
920
- it ( 'should remove placeholder for next/image correctly' , async ( ) => {
921
- const browser = await webdriver ( context . appPort , '/' )
922
-
923
- await browser . eval ( `(function() {
924
- window.beforeNav = 1
925
- window.next.router.push('/static-image')
926
- })()` )
927
- await browser . waitForElementByCss ( '#static-image' )
928
-
929
- expect ( await browser . eval ( 'window.beforeNav' ) ) . toBe ( 1 )
940
+ if ( ! process . env . NEXT_PRIVATE_TEST_WEBPACK4_MODE ) {
941
+ it ( 'should remove placeholder for next/image correctly' , async ( ) => {
942
+ const browser = await webdriver ( context . appPort , '/' )
930
943
931
- await check (
932
- ( ) => browser . elementByCss ( 'img' ) . getComputedCss ( 'background-image' ) ,
933
- 'none'
934
- )
944
+ await browser . eval ( `(function() {
945
+ window.beforeNav = 1
946
+ window.next.router.push('/static-image')
947
+ })()` )
948
+ await browser . waitForElementByCss ( '#static-image' )
935
949
936
- await browser . eval ( `(function() {
937
- window.beforeNav = 1
938
- window.next.router.push('/')
939
- })()` )
940
- await browser . waitForElementByCss ( '.index-page' )
941
- await waitFor ( 1000 )
950
+ expect ( await browser . eval ( 'window.beforeNav' ) ) . toBe ( 1 )
942
951
943
- await browser . eval ( `(function() {
944
- window.beforeNav = 1
945
- window.next.router.push('/static-image')
946
- })()` )
947
- await browser . waitForElementByCss ( '#static-image' )
948
-
949
- expect ( await browser . eval ( 'window.beforeNav' ) ) . toBe ( 1 )
952
+ await check (
953
+ ( ) => browser . elementByCss ( 'img' ) . getComputedCss ( 'background-image' ) ,
954
+ 'none'
955
+ )
950
956
951
- await check (
952
- ( ) =>
953
- browser
954
- . elementByCss ( '#static-image' )
955
- . getComputedCss ( 'background-image' ) ,
956
- 'none'
957
- )
957
+ await browser . eval ( `(function() {
958
+ window.beforeNav = 1
959
+ window.next.router.push('/')
960
+ })()` )
961
+ await browser . waitForElementByCss ( '.index-page' )
962
+ await waitFor ( 1000 )
963
+
964
+ await browser . eval ( `(function() {
965
+ window.beforeNav = 1
966
+ window.next.router.push('/static-image')
967
+ })()` )
968
+ await browser . waitForElementByCss ( '#static-image' )
969
+
970
+ expect ( await browser . eval ( 'window.beforeNav' ) ) . toBe ( 1 )
971
+
972
+ await check (
973
+ ( ) =>
974
+ browser
975
+ . elementByCss ( '#static-image' )
976
+ . getComputedCss ( 'background-image' ) ,
977
+ 'none'
978
+ )
958
979
959
- for ( let i = 0 ; i < 5 ; i ++ ) {
960
- expect (
961
- await browser
962
- . elementByCss ( '#static-image' )
963
- . getComputedCss ( 'background-image' )
964
- ) . toBe ( 'none' )
965
- await waitFor ( 500 )
966
- }
967
- } )
980
+ for ( let i = 0 ; i < 5 ; i ++ ) {
981
+ expect (
982
+ await browser
983
+ . elementByCss ( '#static-image' )
984
+ . getComputedCss ( 'background-image' )
985
+ ) . toBe ( 'none' )
986
+ await waitFor ( 500 )
987
+ }
988
+ } )
989
+ }
968
990
969
991
dynamicImportTests ( context , ( p , q ) => renderViaHTTP ( context . appPort , p , q ) )
970
992
0 commit comments