@@ -9,6 +9,7 @@ const config = require("../fixtures/overlay-config/webpack.config");
99const trustedTypesConfig = require ( "../fixtures/overlay-config/trusted-types.webpack.config" ) ;
1010const runBrowser = require ( "../helpers/run-browser" ) ;
1111const port = require ( "../ports-map" ) . overlay ;
12+ const isWebpack5 = require ( "../helpers/isWebpack5" ) ;
1213
1314class ErrorPlugin {
1415 constructor ( message , skipCounter ) {
@@ -773,80 +774,86 @@ describe("overlay", () => {
773774 await server . stop ( ) ;
774775 } ) ;
775776
776- it ( "should show overlay when Trusted Types are enabled" , async ( ) => {
777- const compiler = webpack ( trustedTypesConfig ) ;
777+ ( isWebpack5 ? it : it . skip ) (
778+ "should show overlay when Trusted Types are enabled" ,
779+ async ( ) => {
780+ const compiler = webpack ( trustedTypesConfig ) ;
778781
779- new ErrorPlugin ( ) . apply ( compiler ) ;
782+ new ErrorPlugin ( ) . apply ( compiler ) ;
780783
781- const devServerOptions = {
782- port,
783- client : {
784- overlay : {
785- trustedTypesPolicyName : "webpack#dev-overlay" ,
784+ const devServerOptions = {
785+ port,
786+ client : {
787+ overlay : {
788+ trustedTypesPolicyName : "webpack#dev-overlay" ,
789+ } ,
786790 } ,
787- } ,
788- } ;
789- const server = new Server ( devServerOptions , compiler ) ;
790-
791- await server . start ( ) ;
792-
793- const { page, browser } = await runBrowser ( ) ;
794-
795- await page . goto ( `http://localhost:${ port } /` , {
796- waitUntil : "networkidle0" ,
797- } ) ;
798-
799- const pageHtml = await page . evaluate ( ( ) => document . body . outerHTML ) ;
800- const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
801- const overlayFrame = await overlayHandle . contentFrame ( ) ;
802- const overlayHtml = await overlayFrame . evaluate (
803- ( ) => document . body . outerHTML
804- ) ;
805-
806- expect ( prettier . format ( pageHtml , { parser : "html" } ) ) . toMatchSnapshot (
807- "page html"
808- ) ;
809- expect ( prettier . format ( overlayHtml , { parser : "html" } ) ) . toMatchSnapshot (
810- "overlay html"
811- ) ;
791+ } ;
792+ const server = new Server ( devServerOptions , compiler ) ;
812793
813- await browser . close ( ) ;
814- await server . stop ( ) ;
815- } ) ;
794+ await server . start ( ) ;
816795
817- it ( "should not show overlay when Trusted Types are enabled, but policy is not allowed" , async ( ) => {
818- const compiler = webpack ( trustedTypesConfig ) ;
796+ const { page, browser } = await runBrowser ( ) ;
819797
820- new ErrorPlugin ( ) . apply ( compiler ) ;
798+ await page . goto ( `http://localhost:${ port } /` , {
799+ waitUntil : "networkidle0" ,
800+ } ) ;
821801
822- const devServerOptions = {
823- port,
824- client : {
825- overlay : {
826- trustedTypesPolicyName : "disallowed-policy" ,
802+ const pageHtml = await page . evaluate ( ( ) => document . body . outerHTML ) ;
803+ const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
804+ const overlayFrame = await overlayHandle . contentFrame ( ) ;
805+ const overlayHtml = await overlayFrame . evaluate (
806+ ( ) => document . body . outerHTML
807+ ) ;
808+
809+ expect ( prettier . format ( pageHtml , { parser : "html" } ) ) . toMatchSnapshot (
810+ "page html"
811+ ) ;
812+ expect ( prettier . format ( overlayHtml , { parser : "html" } ) ) . toMatchSnapshot (
813+ "overlay html"
814+ ) ;
815+
816+ await browser . close ( ) ;
817+ await server . stop ( ) ;
818+ }
819+ ) ;
820+
821+ ( isWebpack5 ? it : it . skip ) (
822+ "should not show overlay when Trusted Types are enabled, but policy is not allowed" ,
823+ async ( ) => {
824+ const compiler = webpack ( trustedTypesConfig ) ;
825+
826+ new ErrorPlugin ( ) . apply ( compiler ) ;
827+
828+ const devServerOptions = {
829+ port,
830+ client : {
831+ overlay : {
832+ trustedTypesPolicyName : "disallowed-policy" ,
833+ } ,
827834 } ,
828- } ,
829- } ;
830- const server = new Server ( devServerOptions , compiler ) ;
835+ } ;
836+ const server = new Server ( devServerOptions , compiler ) ;
831837
832- await server . start ( ) ;
838+ await server . start ( ) ;
833839
834- const { page, browser } = await runBrowser ( ) ;
840+ const { page, browser } = await runBrowser ( ) ;
835841
836- await page . goto ( `http://localhost:${ port } /` , {
837- waitUntil : "networkidle0" ,
838- } ) ;
839-
840- const pageHtml = await page . evaluate ( ( ) => document . body . outerHTML ) ;
841- const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
842- expect ( overlayHandle ) . toBe ( null ) ;
843- expect ( prettier . format ( pageHtml , { parser : "html" } ) ) . toMatchSnapshot (
844- "page html"
845- ) ;
842+ await page . goto ( `http://localhost:${ port } /` , {
843+ waitUntil : "networkidle0" ,
844+ } ) ;
846845
847- await browser . close ( ) ;
848- await server . stop ( ) ;
849- } ) ;
846+ const pageHtml = await page . evaluate ( ( ) => document . body . outerHTML ) ;
847+ const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
848+ expect ( overlayHandle ) . toBe ( null ) ;
849+ expect ( prettier . format ( pageHtml , { parser : "html" } ) ) . toMatchSnapshot (
850+ "page html"
851+ ) ;
852+
853+ await browser . close ( ) ;
854+ await server . stop ( ) ;
855+ }
856+ ) ;
850857
851858 it ( 'should show an error when "client.overlay.errors" is "true"' , async ( ) => {
852859 const compiler = webpack ( config ) ;
0 commit comments