3030import java .util .function .Function ;
3131import java .util .function .Supplier ;
3232import org .junit .jupiter .api .AfterEach ;
33+ import org .junit .jupiter .api .BeforeEach ;
3334import org .junit .jupiter .api .DynamicTest ;
3435import org .junit .jupiter .api .TestFactory ;
3536import org .openqa .selenium .WebDriver ;
3637import org .openqa .selenium .build .InProject ;
3738import org .openqa .selenium .environment .GlobalTestEnvironment ;
39+ import org .openqa .selenium .environment .InProcessTestEnvironment ;
40+ import org .openqa .selenium .environment .TestEnvironment ;
3841import org .openqa .selenium .environment .webserver .AppServer ;
3942import org .openqa .selenium .testing .drivers .WebDriverBuilder ;
4043
@@ -45,6 +48,8 @@ class JavaScriptTestSuite {
4548
4649 private final long timeout ;
4750
51+ private TestEnvironment testEnvironment ;
52+
4853 public JavaScriptTestSuite () {
4954 this .timeout = Math .max (0 , Long .getLong ("js.test.timeout" , 0 ));
5055 this .driverSupplier = new DriverSupplier ();
@@ -54,8 +59,17 @@ private static boolean isBazel() {
5459 return InProject .findRunfilesRoot () != null ;
5560 }
5661
62+ @ BeforeEach
63+ public void setup () {
64+ // this field is actually in use, javascript test do access it
65+ testEnvironment = GlobalTestEnvironment .getOrCreate (InProcessTestEnvironment ::new );
66+ }
67+
5768 @ AfterEach
5869 public void teardown () throws IOException {
70+ if (testEnvironment != null ) {
71+ testEnvironment .stop ();
72+ }
5973 if (driverSupplier != null ) {
6074 ((Closeable ) driverSupplier ).close ();
6175 }
0 commit comments