Closed edler-san closed 6 months ago
I tested and noticed there was for some reason one "M" instead of "m". Fixed that in https://github.com/vaadin/docs/commit/5f85b8d810e22c9936752363fc3dd6561b657a9d
But I'm not 100% sure if that was your issue, because there seems to be some weird package.json errors in your log. Let us know if the issue continues if you fix the selector or is this somethign else?
Thanks for looking into that! With the update I now run into a Spring configuration issue. I am using a simple SpringBoot starter from start.vaadin.com with a "Hello World" view. I attached it for convenience. playwright.zip
10:40:37.167 [ForkJoinPool-1-worker-1] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils -- Could not detect default configuration classes for test class [com.example.TrivialPlaywrightTest]: TrivialPlaywrightTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.552 s <<< FAILURE! -- in com.example.TrivialPlaywrightTest
[ERROR] com.example.TrivialPlaywrightTest -- Time elapsed: 0.552 s <<< ERROR!
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
[...]
Did you try what the error message suggested? That would probably be adding "classes=Application.class" (and related import) to the SpringBootTest annotation. Alternatively move the test to the same package where you have the Application class (but still in src/test/java source directory).
I actually did that previously, yet the test still crashed and burned. Moving the test class to src\test\java\com\example\application\views\helloworld\TrivialPlaywrightTest.java and adding the view class to the test gives:
[ERROR] Errors:
[ERROR] TrivialPlaywrightTest.testClicking » IllegalState Failed to load ApplicationContext for [WebMergedContextConfiguration@485f70bd testClass = com.example.application.views.helloworld.TrivialPlaywrightTest, locations = [], classes = [com.example.application.views.helloworld.HelloWorldView], contextInitializerClasses = [], activeProfiles = [], propertySourceDescriptors = [], propertySourceProperties = ["org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true", "server.port=0"], contextCustomizers = [org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@297bc4d8, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@3300e7d8, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@372be360, org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@1f, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizer@49c3453b, org.springframework.boot.test.context.SpringBootTestAnnotation@48004231], resourceBasePath = "src/main/webapp", contextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null]
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
The underlying issue seems to be:
Caused by: org.springframework.context.ApplicationContextException: Unable to start web server
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:618)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
at org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137)
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58)
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46)
at org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1454)
at org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:553)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:108)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:225)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:152)
... 21 more
Caused by: org.springframework.boot.web.context.MissingWebServerFactoryBeanException: No qualifying bean of type 'org.springframework.boot.web.servlet.server.ServletWebServerFactory' available: Unable to start AnnotationConfigServletWebServerApplicationContext due to missing ServletWebServerFactory bean
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:216)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:186)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162)
... 35 more
The commonly suggest solution to add @SpringBootApplication
to the Application.java does not apply as the annotation is already there (and the application works just fine with mvn spring-boot:run
). What am I missing?
I tested with your attached project and all fine there with both solutions I suggested 🤷♂️ If you have our support package, try to get somebody from there to help, althought this is purely Spring Boot configuation issue, rather than anything related to Vaadin-Playwright setup.
Thanks for testing. Let's see if I can find a solution.
Tell us about your request
Following https://vaadin.com/docs/latest/testing/playwright I ran into issues executing the tests. Playwright seems to not find the
package.json
even after running a production build to create it and the test fails both in an IDE and the terminal. I tested with OpenJDK 17.0.10, Node 21.7.2 (even though that is not used, see logs), Vaadin version 24.3.8 and 24.0.0.If you think this issue is important, add a 👍 reaction to help the community and maintainers prioritize this issue.