The Hitchhiker's Guide to Testing Spring Boot APIs and Angular Components with Protractor, Jest, Mockito, Wiremock, and Travis CI

The Hitchhiker’s Guide to Testing Spring Boot APIs and Angular Components with Protractor, Jest, Mockito, Wiremock, and Travis CI

This post shows you how to use tools like Jest, Protractor, Travis CI, and WireMock to test your Spring Boot API and Angular components.

tomakehurst

Great post Matt!

One thing worth mentioning - there are actually some shorthands in the Java DSL for WireMock now for common patterns. For instance your first example:


stubFor(get(urlEqualTo("/my/resource"))
.withHeader(“Accept”, equalTo(“text/xml”))
.willReturn(aResponse()
.withStatus(200)
.withHeader(“Content-Type”, “text/xml”)
.withBody("<hello>still using XML</hello>")));

Could be abbreviated to:


stubFor(get("/my/resource")
.withHeader(“Accept”, equalTo(“text/xml”))
.willReturn(okXml("<hello>still using XML</hello>")));

Stef Heyenrath

There is also a .NET version available which can also be used if you prefer a .NET stack.

See https://github.com/WireMock… for more details.

Abhishek

Setting issuer to localhost for wiremock gives me this error -
java.lang.IllegalArgumentException: Your Okta Issuer URL must start with https. Current value: http://localhost:64301/oauth/issuer. You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta…

Any help on this?

Huh I am having similar issues here, but no one is responding: Writing Okta Integration tests for JWT and Opaque token validation

Also just tried to clone the repo down and run the tests they compile but don’t run, all the sample tests fail.

Thanks for reaching out @joseph.tran, I’ve replied to the other thread