function createScenarioFromScaffold({
  name = 'template scenario',
  expectedResult = {
    value: 'this is module two',
  },
  testType = 'deepEqual',
  checkPostRun = async (t, result, err, scenario) => {
    if (err) {
      await /** @type {import('./scenario').ScenarioCheckErrorFn<Result>} */ (
        scenario.checkError
      )(t, err, scenario)
    } else {
      // assumes `result` is not undefined
      await /** @type {import('./scenario').ScenarioCheckResultFn<Result>} */ (
        scenario.checkResult
      )(t, /** @type {Result} */ (result), scenario)
    }
  },
  checkError = async (t, err, scenario) => {
    if (scenario.expectedFailure) {
      t.truthy(err, `Scenario fails as expected: ${scenario.name} - ${err}`)
      t.regex(
        err.message,
        /** @type {RegExp} */ (scenario.expectedFailureMessageRegex),
        'Error message expects to match regex'
      )
    } else {
      if (err) {
        t.fail(`Unexpected error in scenario: ${scenario.name} - ${err}`)
        throw err
      }
    }
  },
  checkResult = async (t, result, scenario) => {
    if (scenario.testType === 'truthy') {
      t.assert(
        result,
        `${scenario.name} - scenario gives expected truthy result`
      )
    } else if (scenario.testType === 'falsy') {
      t.falsy(result, `${scenario.name} - scenario gives expected falsy result`)
    } else {
      t.deepEqual(
        result,
        scenario.expectedResult,
        `${scenario.name} - scenario gives expected result`
      )
    }
  },
  expectedFailure = false,
  expectedFailureMessageRegex = /[\s\S]*/,
  files = {},
  builtin = {},
  context = {},
  opts = {},
  config,
  configOverride,
  defineEntry,
  defineOne,
  defineTwo,
  defineThree,
  defaultPolicy = true,
  dir,
  ...extraArgs
} = {}) {
  function _defineEntry() {
    // @ts-expect-error - does not exist
    const testResult = require('one')
    console.log(JSON.stringify(testResult, null, 2))
  }

  function _defineOne() {
    // @ts-expect-error - does not exist
    module.exports = require('two')
  }

  function _defineTwo() {
    module.exports = {
      value: 'this is module two',
    }
  }

  function _defineThree() {
    module.exports = {
      value: 'this is module three',
    }
  }

  const _files = fillInFileDetails({
    'entry.js': {
      content: `(${defineEntry || _defineEntry}).call(this)`,
      packageName: '$root$',
      importMap: {
        one: 'node_modules/one/index.js',
        two: 'node_modules/two/index.js',
        three: 'node_modules/three/index.js',
      },
      entry: true,
    },
    'package.json': {
      content: `${JSON.stringify(
        {
          name,
          dependencies: {
            one: '1.0.0',
            two: '1.0.0',
            three: '1.0.0',
          },
          devDependencies: {},
        },
        null,
        2
      )}`,
    },
    'node_modules/one/index.js': {
      packageName: 'one',
      content: `(${defineOne || _defineOne}).call(this)`,
      importMap: {
        two: 'node_modules/two/index.js',
        three: 'node_modules/three/index.js',
      },
    },
    'node_modules/one/package.json': {
      content: `${JSON.stringify(
        {
          name: 'one',
          dependencies: {
            two: '1.0.0',
            three: '1.0.0',
          },
        },
        null,
        2
      )}`,
    },
    'node_modules/two/index.js': {
      packageName: 'two',
      content: `(${defineTwo || _defineTwo}).call(this)`,
      importMap: {
        three: 'node_modules/three/index.js',
      },
    },
    'node_modules/two/package.json': {
      content: `${JSON.stringify(
        {
          name: 'two',
          dependencies: {
            three: '1.0.0',
          },
        },
        null,
        2
      )}`,
    },
    'node_modules/three/index.js': {
      packageName: 'three',
      content: `(${defineThree || _defineThree}).call(this)`,
      importMap: {
        one: 'node_modules/one/index.js',
      },
    },
    'node_modules/three/package.json': {
      content: `${JSON.stringify(
        {
          name: 'three',
          dependencies: {
            one: '1.0.0',
          },
        },
        null,
        2
      )}`,
    },
    ...files,
  })

  let _config
  if (defaultPolicy) {
    _config = mergeDeep(
      {
        resources: {
          one: {
            packages: {
              two: true,
              three: true,
            },
          },
          two: {
            packages: {
              three: true,
            },
          },
        },
      },
      config
    )
  } else {
    _config = config
  }

  const _configOverride = mergeDeep(
    {
      resources: {
        one: {
          packages: {
            five: true,
          },
        },
      },
    },
    configOverride
  )

  if (!hasOwn(opts, 'scuttleGlobalThis')) {
    opts.scuttleGlobalThis = {}
  }

  return {
    ...extraArgs,
    name: name,
    checkPostRun,
    checkResult,
    checkError,
    testType,
    builtin,
    expectedResult,
    expectedFailure,
    expectedFailureMessageRegex,
    entries: ['entry.js'],
    files: _files,
    config: /** @type {import('../src/schema').LavaMoatPolicy} */ (_config),
    configOverride:
      /** @type {import('../src/schema').LavaMoatPolicyOverrides} */ (
        _configOverride
      ),
    context,
    opts,
    dir,
  }
}
Given an incomplete scenario definition, normalize it in preparation for
running.

@template [Result=unknown] Default is `unknown`
@param {import('./scenario').Scenario} scenario
@returns {import('./scenario').NormalizedScenario<{ value: string }>}