Now that Nashorn has been deprecated & removed in JDK 15 what is the best approach to validate that a String is valid Javascript in a JUnit test?
Previous Code:
private void validateJavascript(final String js) throws ScriptException {
final NashornScriptEngine scriptEngine = (NashornScriptEngine) new NashornScriptEngineFactory().getScriptEngine();
final CompiledScript compile = scriptEngine.compile(js);
}
Found the following similar thread Different Nashorn engine for Java < 15 and >= 15? which pointed me to standalone implementation which can be added as a test dependency:
And then instantiated as follows: