Chapter 15. Testing JavaScript Using Spock

So far, we’ve used Spock exclusively to test Java code. One of the reasons all of the examples in the book use Java is that I want to stress that Spock is able to test more than just Groovy. However, Java is not the only other language that we can test using Spock.

In this chapter, we take a brief look at testing JavaScript using Spock. We’ll use the Nashorn script engine (introduced in Java 8) to evaluate JavaScript and invoke it from Spock.

Why Test JavaScript from the JVM?

Why would we want to test JavaScript code from the JVM when JavaScript has its own rich suite of ...

Get Spock: Up and Running now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.