22/* eslint-disable jest/expect-expect */
33import path from "path" ;
44import { spawn } from "child_process" ;
5+ import { testIfNodeMajorVersionIsLessThan18 } from "../../utils/testIf" ;
56
67jest . setTimeout ( 10_000 ) ;
78
@@ -26,7 +27,7 @@ describe("Error throwing by default (no errorHandler)", () => {
2627 sentryServer . kill ( ) ;
2728 } ) ;
2829
29- test . each ( [ "vite" , "rollup" , "webpack5" , "webpack4" , " esbuild"] ) (
30+ test . each ( [ "vite" , "rollup" , "webpack5" , "esbuild" ] ) (
3031 "doesn't throw when Sentry server responds with error code for %s" ,
3132 async ( bundler ) => {
3233 const buildProcess = spawn ( "yarn" , [ "ts-node" , path . join ( __dirname , `build-${ bundler } .ts` ) ] , {
@@ -49,4 +50,28 @@ describe("Error throwing by default (no errorHandler)", () => {
4950 buildProcess . kill ( ) ;
5051 }
5152 ) ;
53+
54+ testIfNodeMajorVersionIsLessThan18 (
55+ "doesn't throw when Sentry server responds with error code for webpack 4" ,
56+ async ( ) => {
57+ const buildProcess = spawn ( "yarn" , [ "ts-node" , path . join ( __dirname , `build-webpack4.ts` ) ] , {
58+ env : { ...process . env , FAKE_SENTRY_PORT } ,
59+ stdio : "ignore" , // <-- set to "inherit" to get build output. Deactivated to avoid spamming test logs.
60+ } ) ;
61+
62+ const exitCode = await new Promise < number > ( ( resolve , reject ) => {
63+ buildProcess . on ( "exit" , ( code ) => {
64+ resolve ( code ?? 99 ) ;
65+ } ) ;
66+
67+ buildProcess . on ( "error" , ( err ) => {
68+ reject ( err ) ;
69+ } ) ;
70+ } ) ;
71+
72+ expect ( exitCode ) . toBe ( 0 ) ;
73+
74+ buildProcess . kill ( ) ;
75+ }
76+ ) ;
5277} ) ;
0 commit comments