Skip to content

Commit

Permalink
feat: set EXODUS_TEST_PLATFORM/ENGINE env before loading jest config
Browse files Browse the repository at this point in the history
  • Loading branch information
ChALkeR committed Sep 9, 2024
1 parent 1700d0a commit 8395284
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,18 @@ const { options, patterns } = parseOptions()
const warnHuman = isTTY && !isCI ? (...args) => console.warn(...args) : () => {}
if (isCI) process.env.FORCE_COLOR = '1' // should support colored output even though not a TTY, overridable with --no-color

const setEnv = (name, value) => {
const env = process.env[name]
if (env && env !== value) throw new Error(`env conflict: ${name}="${env}", effective: "${value}"`)
process.env[name] = value
}

const engineOptions = ENGINES.get(options.engine)
assert(engineOptions, `Unknown engine: ${options.engine}`)
Object.assign(options, engineOptions)
options.platform = options.binary // binary can be overriden by c8
setEnv('EXODUS_TEST_ENGINE', options.engine) // e.g. 'hermes:bundle', 'node:bundle', 'node:test', 'node:pure'
setEnv('EXODUS_TEST_PLATFORM', options.binary) // e.g. 'hermes', 'node'

const require = createRequire(import.meta.url)
const resolveRequire = (query) => require.resolve(query)
Expand Down Expand Up @@ -404,15 +412,6 @@ if (!options.bundle) {
}

if (!Object.hasOwn(process.env, 'NODE_ENV')) process.env.NODE_ENV = 'test'

const setEnv = (name, value) => {
const env = process.env[name]
if (env && env !== value) throw new Error(`env conflict: ${name}="${env}", effective: "${value}"`)
process.env[name] = value
}

setEnv('EXODUS_TEST_PLATFORM', options.binary) // e.g. 'hermes', 'node'
setEnv('EXODUS_TEST_ENGINE', options.engine) // e.g. 'hermes:bundle', 'node:bundle', 'node:test', 'node:pure'
setEnv('EXODUS_TEST_ONLY', options.only ? '1' : '')

const c8 = resolveRequire('c8/bin/c8.js')
Expand Down

0 comments on commit 8395284

Please sign in to comment.