MCPcopy
hub / github.com/rolldown/tsdown / testBuild

Function testBuild

tests/utils.ts:117–238  ·  view source on GitHub ↗
({
  context,
  files,
  fixture,
  options,
  cwd,
  expectDir = '.',
  expectPattern,
  beforeBuild,
  snapshot: shouldSnapshot = true,
  prettier,
}: TestBuildOptions)

Source from the content-addressed store, hash-verified

115}
116
117export async function testBuild({
118 context,
119 files,
120 fixture,
121 options,
122 cwd,
123 expectDir = '.',
124 expectPattern,
125 beforeBuild,
126 snapshot: shouldSnapshot = true,
127 prettier,
128}: TestBuildOptions): Promise<{
129 testName: string
130 testDir: string
131 outputFiles: string[]
132 outputDir: string
133 snapshot: string
134 fileMap: Record<string, string>
135 warnings: RollupLog[]
136 bundle: TsdownBundle[]
137}> {
138 const { expect } = context
139 const { testName, testDir } = await writeFixtures(context, files, fixture)
140
141 const workingDir = path.join(testDir, cwd || '.')
142 const restoreCwd = chdir(workingDir)
143 const warnings: RollupLog[] = []
144 const userOptions =
145 typeof options === 'function' ? options(workingDir) : options
146 const resolvedOptions: InlineConfig = {
147 entry: 'index.ts',
148 config: false,
149 outDir: 'dist',
150 dts: false,
151 logLevel: 'silent',
152 tsconfig: false,
153 failOnWarn: false,
154 ...userOptions,
155 async inputOptions(options, ...args) {
156 const originalOnLog = options.onLog
157 options = await mergeUserOptions(
158 {
159 ...options,
160 onLog(level, log, defaultHandler) {
161 if (level === 'warn') {
162 warnings.push(log)
163 }
164 const _defaultHandler: LogOrStringHandler = (level, ...args) => {
165 if (level !== 'error') return
166 defaultHandler(level, ...args)
167 }
168 if (originalOnLog) {
169 originalOnLog(level, log, _defaultHandler)
170 } else {
171 _defaultHandler(level, log)
172 }
173 },
174 logLevel: 'info',

Callers 9

clean.test.tsFile · 0.90
issues.test.tsFile · 0.90
css.test.tsFile · 0.90
target.test.tsFile · 0.90
e2e.test.tsFile · 0.90
unbundle.test.tsFile · 0.90
shims.test.tsFile · 0.90
exe.test.tsFile · 0.90

Calls 3

buildFunction · 0.90
writeFixturesFunction · 0.85
chdirFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…