mirror of
https://github.com/erlef/setup-beam.git
synced 2026-07-23 07:06:07 +00:00
fix: use dynamic import in tests to prevent ESM hoisting race (#429)
Static ESM imports are hoisted above top-level statements, causing setup-beam.js to evaluate its main() guard before process.env.NODE_ENV is set to 'test'. This triggered core.setFailed() during module load, setting process.exitCode=1 and failing the test file even though all individual test cases passed. Switch setup-beam.js to a dynamic await import() so that the env and input setup runs first, ensuring the NODE_ENV='test' guard works correctly. Amp-Thread-ID: https://ampcode.com/threads/T-019ce36a-a18f-7494-ac0a-c094a84f06ad Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
committed by
GitHub
parent
d843ebb78b
commit
f018c1e6d8
+11
-10
@@ -1,3 +1,13 @@
|
||||
import assert from 'node:assert'
|
||||
import http from 'node:http'
|
||||
import fs from 'node:fs'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import { describe, it } from 'node:test'
|
||||
import * as csv from 'csv-parse/sync'
|
||||
import elixirMatchers from '../matchers/elixir-matchers.json' with { type: 'json' }
|
||||
const { problemMatcher } = elixirMatchers
|
||||
|
||||
process.env.NODE_ENV = 'test'
|
||||
|
||||
simulateInput('otp-version', '25.1.2')
|
||||
@@ -9,16 +19,7 @@ simulateInput('install-hex', 'true')
|
||||
simulateInput('github-token', process.env.GITHUB_TOKEN)
|
||||
simulateInput('hexpm-mirrors', 'https://builds.hex.pm', { multiline: true })
|
||||
|
||||
import assert from 'node:assert'
|
||||
import http from 'node:http'
|
||||
import fs from 'node:fs'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import { describe, it } from 'node:test'
|
||||
import * as csv from 'csv-parse/sync'
|
||||
import setupBeam from '../src/setup-beam.js'
|
||||
import elixirMatchers from '../matchers/elixir-matchers.json' with { type: 'json' }
|
||||
const { problemMatcher } = elixirMatchers
|
||||
const { default: setupBeam } = await import('../src/setup-beam.js')
|
||||
|
||||
const matrix = {
|
||||
otp: {
|
||||
|
||||
Reference in New Issue
Block a user