tests/testthat/test_modules.R

context("ESM modules")

test_that("get modules", {
  skip_if(V8::engine_info()$numeric_version < "6.3")
  ctx <- V8::v8()
  ctx$source('modules/main.js')
  expect_error(ctx$eval('test_bad_path()', await = TRUE), "path")
  expect_equal(ctx$eval('run_test()', await = TRUE), "579")
  expect_error(ctx$eval('test_syntax_error1()', await = TRUE), "SyntaxError")
  expect_equal(ctx$eval('run_test()', await = TRUE), "579")
})

Try the V8 package in your browser

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

V8 documentation built on Oct. 12, 2024, 5:06 p.m.