tests/e2e/test-format-js.R

rhino::format_js()

# Create bad scripts and test if formatting returns the expected result
test_file_path <- fs::path("app", "js", "bad-style.js")
cat('const  someFunction = (a ,b) => a+ b + "asdf"', file = test_file_path)
rhino::format_js()
testthat::expect_identical(
  readLines(test_file_path),
  "const someFunction = (a, b) => a + b + 'asdf';"
)

# Clean up
file.remove(test_file_path)

Try the rhino package in your browser

Any scripts or data that you put into this service are public.

rhino documentation built on Sept. 20, 2024, 5:10 p.m.