async function runScenario({ scenario, runWithPrecompiledModules = false }) {
  const {
    entries,
    files,
    config,
    configOverride,
    builtin,
    kernelArgs = {},
    opts = {},
    beforeCreateKernel = () => {},
  } = scenario
  const lavamoatConfig = mergeDeep(config, configOverride)
  const kernelSrc = generateKernel(opts)
  const { hookedConsole, firstLogEventPromise } = createHookedConsole()
  Object.assign(scenario.context, { console: hookedConsole })
  const {
    result: createKernel,
    vmGlobalThis,
    vmContext,
    vmFeralFunction,
  } = evaluateWithSourceUrl(
    'LavaMoat/core-test/kernel',
    kernelSrc,
    scenario.context
  )
  // root global for test realm
  scenario.globalThis = vmGlobalThis
  scenario.vmContext = vmContext
  // call hook before kernel is created
  beforeCreateKernel(scenario)
  // create kernel
  const kernel = createKernel({
    ...opts,
    runWithPrecompiledModules,
    lavamoatConfig,
    /** @param {string} id */
    loadModuleData: (id) => {
      if (id in builtin) {
        return moduleDataForBuiltin(builtin, id)
      }
      const moduleRecord = files[id]
      /**
       * @type {any}
       * @todo Need a type for "module data"
       */
      const moduleData = {
        id: moduleRecord.specifier,
        package: moduleRecord.packageName,
        type: moduleRecord.type,
        file: moduleRecord.file,
        deps: moduleRecord.importMap,
        moduleInitializer: moduleRecord.moduleInitializer,
      }
      // append the source or prepare the precompiledInitializer
      const intializerSource = `(function(exports, require, module, __filename, __dirname){\n${applySourceTransforms(
        moduleRecord.content
      )}\n})`
      if (runWithPrecompiledModules) {
        moduleData.precompiledInitializer = vmFeralFunction(`
          with (this.scopeTerminator) {
          with (this.globalThis) {
            return function() {
              'use strict';
              return ${intializerSource}
            };
          }
          }
        `)
      } else {
        moduleData.source = intializerSource
      }
      return moduleData
    },
    /**
     * @param {string} id
     * @param {string} relative
     * @returns {string}
     */
    getRelativeModuleId: (id, relative) => {
      return (
        /** @type {import('./scenario').NormalizedScenarioJSFile} */ (files[id])
          .importMap[relative] || relative
      )
    },
    prepareModuleInitializerArgs,
    ...kernelArgs,
  })

  entries.forEach((id) => kernel.internalRequire(id))
  const testResult = await firstLogEventPromise
  return testResult
}
Run the given scenario.

The `scenario` itself should be passed thru `createScenarioFromScaffold` to
normalize it.

@template [Result=unknown] Default is `unknown`
@type {PlatformRunScenario<Result>}