| 1 |
/* eslint-env jest */ |
| 2 |
import * as babelscip-typescript npm @babel/core 7.20.12 src/`index.ts`/ from "@babel/core"scip-typescript npm @babel/core 7.20.12 src/`index.ts`/; |
| 3 |
import { |
| 4 |
buildExternalHelpers, |
| 5 |
type InputOptionsscip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/InputOptions#, |
| 6 |
type FileResultscip-typescript npm @babel/core 7.20.12 src/transformation/`index.ts`/FileResult#, |
| 7 |
} from "@babel/core"scip-typescript npm @babel/core 7.20.12 src/`index.ts`/; |
| 8 |
import { |
| 9 |
defaultscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/get(). as getFixturesscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/get()., |
| 10 |
resolveOptionPluginOrPresetscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset()., |
| 11 |
type Testscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#, |
| 12 |
type TestFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#, |
| 13 |
type TaskOptionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#, |
| 14 |
} from "@babel/helper-fixtures"scip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/; |
| 15 |
import { codeFrameColumnsscip-typescript npm @babel/code-frame 7.18.6 src/`index.ts`/codeFrameColumns(). } from "@babel/code-frame"scip-typescript npm @babel/code-frame 7.18.6 src/`index.ts`/; |
| 16 |
import * as helpersscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`helpers.ts`/ from "./helpers"scip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`helpers.ts`/; |
| 17 |
import assert from "assert"; |
| 18 |
import fs from "fs"; |
| 19 |
import path from "path"; |
| 20 |
import vm from "vm"; |
| 21 |
import QuickLRU from "quick-lru"; |
| 22 |
import { fileURLToPath } from "url"; |
| 23 |
|
| 24 |
import { createRequire } from "module"; |
| 25 |
const requirescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/require. = createRequire(import.meta.urlscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/ImportMeta#url.); |
| 26 |
|
| 27 |
import checkDuplicateNodesscip-typescript npm @babel/helper-check-duplicate-nodes 7.18.6 src/`index.ts`/checkDuplicateNodes(). from "@babel/helper-check-duplicate-nodes"scip-typescript npm @babel/helper-check-duplicate-nodes 7.18.6 src/`index.ts`/; |
| 28 |
|
| 29 |
type Modulescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/Module# = { |
| 30 |
idscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/Module#typeLiteral8:id.: string; |
| 31 |
exportsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/Module#typeLiteral8:exports.: Recordscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Record#<string, unknown>; |
| 32 |
}; |
| 33 |
|
| 34 |
if (!process.env.BABEL_8_BREAKING) { |
| 35 |
// Introduced in Node.js 10 |
| 36 |
if (!assert.rejects) { |
| 37 |
assert.rejects = async function (block, validateError) { |
| 38 |
try { |
| 39 |
await (typeof block === "function" ? block() : block); |
| 40 |
return Promisescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Promise#.rejectscip-typescript npm typescript 5.9.3 lib/`lib.es2015.promise.d.ts`/PromiseConstructor#reject().(new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#("Promise not rejected")); |
| 41 |
} catch (error) { |
| 42 |
// @ts-expect-error Fixme: validateError can be a string | object |
| 43 |
// see https://nodejs.org/api/assert.html#assertrejectsasyncfn-error-message |
| 44 |
if (typeof validateError === "function" && !validateError(error)) { |
| 45 |
return Promisescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Promise#.rejectscip-typescript npm typescript 5.9.3 lib/`lib.es2015.promise.d.ts`/PromiseConstructor#reject().( |
| 46 |
new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#("Promise rejected with invalid error"), |
| 47 |
); |
| 48 |
} |
| 49 |
} |
| 50 |
}; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
const EXTERNAL_HELPERS_VERSIONscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/EXTERNAL_HELPERS_VERSION. = "7.100.0"; |
| 55 |
|
| 56 |
const cachedScriptsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/cachedScripts. = new QuickLRU< |
| 57 |
string, |
| 58 |
{ code: string; cachedData?: Buffer } |
| 59 |
>({ maxSizescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/maxSize0:: 10 }); |
| 60 |
const contextModuleCachescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/contextModuleCache. = new WeakMapscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/WeakMap#(); |
| 61 |
const sharedTestContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/sharedTestContext. = createContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/createContext().(); |
| 62 |
|
| 63 |
// We never want our tests to accidentally load the root |
| 64 |
// babel.config.js file, so we disable config loading by |
| 65 |
// default. Tests can still set `configFile: true | string` |
| 66 |
// to re-enable config loading. |
| 67 |
function transformWithoutConfigFilescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformWithoutConfigFile().(codescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformWithoutConfigFile().(code): string, optsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformWithoutConfigFile().(opts): InputOptionsscip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/InputOptions#) { |
| 68 |
return babelscip-typescript npm @babel/core 7.20.12 src/`index.ts`/.transformSync(codescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformWithoutConfigFile().(code), { |
| 69 |
configFilescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/configFile0:: false, |
| 70 |
babelrcscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/babelrc0:: false, |
| 71 |
...optsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformWithoutConfigFile().(opts), |
| 72 |
}); |
| 73 |
} |
| 74 |
function transformAsyncWithoutConfigFilescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformAsyncWithoutConfigFile().(codescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformAsyncWithoutConfigFile().(code): string, optsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformAsyncWithoutConfigFile().(opts): InputOptionsscip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/InputOptions#) { |
| 75 |
return babelscip-typescript npm @babel/core 7.20.12 src/`index.ts`/.transformAsync(codescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformAsyncWithoutConfigFile().(code), { |
| 76 |
configFilescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/configFile1:: false, |
| 77 |
babelrcscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/babelrc1:: false, |
| 78 |
...optsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformAsyncWithoutConfigFile().(opts), |
| 79 |
}); |
| 80 |
} |
| 81 |
|
| 82 |
function createContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/createContext().() { |
| 83 |
const context = vm.createContext({ |
| 84 |
...helpersscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`helpers.ts`/, |
| 85 |
processscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/process0:: process, |
| 86 |
transformscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transform0:: transformWithoutConfigFilescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformWithoutConfigFile()., |
| 87 |
transformAsyncscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformAsync0:: transformAsyncWithoutConfigFilescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/transformAsyncWithoutConfigFile()., |
| 88 |
setTimeoutscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/setTimeout0:: setTimeoutscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/setTimeout()., |
| 89 |
setImmediatescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/setImmediate0:: setImmediate, |
| 90 |
expectscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/expect0:, |
| 91 |
}); |
| 92 |
context.global = context; |
| 93 |
|
| 94 |
const moduleCache = Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.createscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#create().(null); |
| 95 |
contextModuleCachescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/contextModuleCache..setscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/WeakMap#set().(context, moduleCache); |
| 96 |
|
| 97 |
// Populate the "babelHelpers" global with Babel's helper utilities. |
| 98 |
runCacheableScriptInTestContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().( |
| 99 |
path.join( |
| 100 |
path.dirname(fileURLToPath(import.meta.urlscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/ImportMeta#url.)), |
| 101 |
"babel-helpers-in-memory.js", |
| 102 |
), |
| 103 |
buildExternalHelpers, |
| 104 |
context, |
| 105 |
moduleCache, |
| 106 |
); |
| 107 |
|
| 108 |
return context; |
| 109 |
} |
| 110 |
|
| 111 |
function runCacheableScriptInTestContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().( |
| 112 |
filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(filename): string, |
| 113 |
srcFnscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(srcFn): () => string, |
| 114 |
contextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(context): vm.Context, |
| 115 |
moduleCachescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(moduleCache): any, |
| 116 |
): Modulescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/Module# { |
| 117 |
let cached = cachedScriptsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/cachedScripts..get(filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(filename)); |
| 118 |
if (!cached) { |
| 119 |
const code = `(function (exports, require, module, __filename, __dirname) {\n${srcFnscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(srcFn)()}\n});`; |
| 120 |
cached = { |
| 121 |
codescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/code0:, |
| 122 |
cachedDatascip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/cachedData0:: undefined, |
| 123 |
}; |
| 124 |
cachedScriptsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/cachedScripts..set(filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(filename), cached); |
| 125 |
} |
| 126 |
|
| 127 |
let script: vm.Script; |
| 128 |
if (process.env.BABEL_8_BREAKING) { |
| 129 |
script = new vm.Script(cached.code, { |
| 130 |
filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/filename0:, |
| 131 |
lineOffsetscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/lineOffset0:: -1, |
| 132 |
cachedDatascip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/cachedData1:: cached.cachedData, |
| 133 |
}); |
| 134 |
cached.cachedData = script.createCachedData(); |
| 135 |
} else { |
| 136 |
script = new vm.Script(cached.code, { |
| 137 |
filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/filename1:, |
| 138 |
lineOffsetscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/lineOffset1:: -1, |
| 139 |
cachedDatascip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/cachedData2:: cached.cachedData, |
| 140 |
produceCachedDatascip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/produceCachedData0:: true, |
| 141 |
}); |
| •142 |
// @ts-ignore |
| 143 |
if (script.cachedDataProduced) { |
| •144 |
// @ts-ignore |
| 145 |
cached.cachedData = script.cachedData; |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
const module = { |
| 150 |
idscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/id0:: filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(filename), |
| 151 |
exportsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/exports0:: {}, |
| 152 |
}; |
| 153 |
moduleCachescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(moduleCache)[filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(filename)] = module; |
| 154 |
|
| 155 |
const req = (id: string) => |
| 156 |
runModuleInTestContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(id, filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(filename), contextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(context), moduleCachescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(moduleCache)); |
| 157 |
const dirname = path.dirname(filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(filename)); |
| 158 |
|
| 159 |
script |
| 160 |
.runInContext(contextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(context)) |
| 161 |
.call(module.exportsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/exports0:, module.exportsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/exports0:, req, module, filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().(filename), dirname); |
| 162 |
|
| 163 |
return module; |
| 164 |
} |
| 165 |
|
| 166 |
/** |
| 167 |
* A basic implementation of CommonJS so we can execute `@babel/polyfill` inside our test context. |
| 168 |
* This allows us to run our unittests |
| 169 |
*/ |
| 170 |
function runModuleInTestContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().( |
| 171 |
idscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(id): string, |
| 172 |
relativeFilenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(relativeFilename): string, |
| 173 |
contextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(context): vm.Context, |
| 174 |
moduleCachescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(moduleCache): any, |
| 175 |
) { |
| 176 |
const filename = requirescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/require..resolve(idscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(id), { |
| 177 |
pathsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/paths0:: [path.dirname(relativeFilenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(relativeFilename))], |
| 178 |
}); |
| 179 |
|
| 180 |
// Expose Node-internal modules if the tests want them. Note, this will not execute inside |
| 181 |
// the context's global scope. |
| 182 |
if (filename === idscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(id)) return requirescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/require.(idscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(id)); |
| 183 |
|
| 184 |
// Modules can only evaluate once per context, so the moduleCache is a |
| 185 |
// stronger cache guarantee than the LRU's Script cache. |
| 186 |
if (moduleCachescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(moduleCache)[filename]) return moduleCachescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(moduleCache)[filename].exports; |
| 187 |
|
| 188 |
return runCacheableScriptInTestContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCacheableScriptInTestContext().( |
| 189 |
filename, |
| 190 |
() => fs.readFileSync(filename, "utf8"), |
| 191 |
contextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(context), |
| 192 |
moduleCachescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(moduleCache), |
| 193 |
).exportsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/Module#typeLiteral8:exports.; |
| 194 |
} |
| 195 |
|
| 196 |
/** |
| 197 |
* Run the given snippet of code inside a CommonJS module. |
| 198 |
* |
| 199 |
* Exposed for unit tests, not for use as an API. |
| 200 |
*/ |
| 201 |
export function runCodeInTestContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().( |
| 202 |
codescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(code): string, |
| 203 |
optsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(opts): { |
| 204 |
filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(opts)typeLiteral54:filename.: string; |
| 205 |
}, |
| 206 |
contextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(context) = sharedTestContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/sharedTestContext., |
| 207 |
) { |
| 208 |
const filename = optsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(opts).filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(opts)typeLiteral54:filename.; |
| 209 |
const dirname = path.dirname(filename); |
| 210 |
const moduleCache = contextModuleCachescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/contextModuleCache..getscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/WeakMap#get().(contextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(context)); |
| 211 |
const req = (id: string) => |
| 212 |
runModuleInTestContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runModuleInTestContext().(id, filename, contextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(context), moduleCache); |
| 213 |
|
| 214 |
const module: Modulescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/Module# = { |
| 215 |
idscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/Module#typeLiteral8:id.: filename, |
| 216 |
exportsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/Module#typeLiteral8:exports.: {}, |
| 217 |
}; |
| 218 |
|
| 219 |
const oldCwd = process.cwd(); |
| 220 |
try { |
| 221 |
if (optsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(opts).filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(opts)typeLiteral54:filename.) process.chdir(path.dirname(optsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(opts).filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(opts)typeLiteral54:filename.)); |
| 222 |
|
| 223 |
// Expose the test options as "opts", but otherwise run the test in a CommonJS-like environment. |
| 224 |
// Note: This isn't doing .call(module.exports, ...) because some of our tests currently |
| 225 |
// rely on 'this === global'. |
| 226 |
const src = `(function(exports, require, module, __filename, __dirname, opts) {\n${codescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(code)}\n});`; |
| 227 |
return vm.runInContext(src, contextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(context), { |
| 228 |
filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/filename2:, |
| 229 |
displayErrorsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/displayErrors0:: true, |
| 230 |
lineOffsetscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/lineOffset2:: -1, |
| 231 |
})(module.exportsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/Module#typeLiteral8:exports., req, module, filename, dirname, optsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(opts)); |
| 232 |
} finally { |
| 233 |
process.chdir(oldCwd); |
| 234 |
} |
| 235 |
} |
| 236 |
|
| 237 |
async function maybeMockConsolescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/maybeMockConsole().<Rscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/maybeMockConsole().[R]>(validateLogsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/maybeMockConsole().(validateLogs): boolean, runscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/maybeMockConsole().(run): () => Rscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/maybeMockConsole().[R]) { |
| 238 |
const actualLogs = { stdoutscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/stdout0:: "", stderrscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/stderr0:: "" }; |
| 239 |
|
| 240 |
if (!validateLogsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/maybeMockConsole().(validateLogs)) return { resultscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/result0:: await runscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/maybeMockConsole().(run)(), actualLogsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/actualLogs0: }; |
| 241 |
|
| 242 |
const spy1 = jest.spyOn(consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console., "log").mockImplementation(msg => { |
| 243 |
actualLogs.stdoutscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/stdout0: += `${msg}\n`; |
| 244 |
}); |
| 245 |
const spy2 = jest.spyOn(consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console., "warn").mockImplementation(msg => { |
| 246 |
actualLogs.stderrscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/stderr0: += `${msg}\n`; |
| 247 |
}); |
| 248 |
|
| 249 |
try { |
| 250 |
return { resultscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/result1:: await runscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/maybeMockConsole().(run)(), actualLogsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/actualLogs1: }; |
| 251 |
} finally { |
| 252 |
spy1.mockRestore(); |
| 253 |
spy2.mockRestore(); |
| 254 |
} |
| 255 |
} |
| 256 |
|
| 257 |
async function runscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/run().(taskscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/run().(task): Testscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#) { |
| 258 |
const { |
| 259 |
actualscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#actual., |
| 260 |
expectscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#expect.: expected, |
| 261 |
execscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#exec., |
| 262 |
optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options.: opts, |
| 263 |
doNotSetSourceTypescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#doNotSetSourceType., |
| 264 |
optionsDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#optionsDir., |
| 265 |
validateLogsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#validateLogs., |
| 266 |
ignoreOutputscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#ignoreOutput., |
| 267 |
stdoutscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#stdout., |
| 268 |
stderrscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#stderr., |
| 269 |
} = taskscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/run().(task); |
| 270 |
|
| 271 |
// todo(flow->ts) add proper return type (added any, because empty object is inferred) |
| 272 |
function getOpts(self: TestFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#): any { |
| 273 |
const newOpts = { |
| 274 |
astscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/ast0:: true, |
| 275 |
cwdscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/cwd0:: path.dirname(self.locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.), |
| 276 |
filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/filename3:: self.locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc., |
| 277 |
filenameRelativescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/filenameRelative0:: self.filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#filename., |
| 278 |
sourceFileNamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/sourceFileName0:: self.filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#filename., |
| 279 |
...(doNotSetSourceType ? {} : { sourceTypescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/sourceType0:: "script" }), |
| 280 |
babelrcscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/babelrc2:: false, |
| 281 |
configFilescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/configFile2:: false, |
| 282 |
inputSourceMapscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/inputSourceMap0:: taskscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/run().(task).inputSourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#inputSourceMap. || undefined, |
| 283 |
...opts, |
| 284 |
}; |
| 285 |
|
| 286 |
return resolveOptionPluginOrPresetscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(newOpts, optionsDir); |
| 287 |
} |
| 288 |
|
| 289 |
let execCode = exec.codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.; |
| 290 |
let result: FileResultscip-typescript npm @babel/core 7.20.12 src/transformation/`index.ts`/FileResult#; |
| 291 |
let resultExec; |
| 292 |
|
| 293 |
if (execCode) { |
| 294 |
const context = createContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/createContext().(); |
| 295 |
const execOpts = getOpts(exec); |
| 296 |
|
| 297 |
// Ignore Babel logs of exec.js files. |
| 298 |
// They will be validated in input/output files. |
| 299 |
({ resultscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/result2: } = await maybeMockConsolescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/maybeMockConsole().(validateLogs, () => |
| 300 |
babelscip-typescript npm @babel/core 7.20.12 src/`index.ts`/.transformAsync(execCode, execOpts), |
| 301 |
)); |
| 302 |
|
| 303 |
checkDuplicateNodesscip-typescript npm @babel/helper-check-duplicate-nodes 7.18.6 src/`index.ts`/checkDuplicateNodes().(result.astscip-typescript npm @babel/core 7.20.12 src/transformation/`index.ts`/FileResult#typeLiteral44:ast.); |
| 304 |
execCode = result.codescip-typescript npm @babel/core 7.20.12 src/transformation/`index.ts`/FileResult#typeLiteral44:code.; |
| 305 |
|
| 306 |
try { |
| 307 |
resultExec = runCodeInTestContextscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/runCodeInTestContext().(execCode, execOpts, context); |
| 308 |
} catch (err) { |
| 309 |
// Pass empty location to include the whole file in the output. |
| 310 |
err.message = |
| 311 |
`${exec.locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.}: ${err.message}\n` + codeFrameColumnsscip-typescript npm @babel/code-frame 7.18.6 src/`index.ts`/codeFrameColumns().(execCode, {} as any); |
| 312 |
throw err; |
| 313 |
} |
| 314 |
} |
| 315 |
|
| 316 |
const inputCode = actual.codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.; |
| 317 |
const expectedCode = expected.codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.; |
| 318 |
if (!execCode || inputCode) { |
| 319 |
let actualLogs; |
| 320 |
|
| 321 |
({ resultscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/result3:, actualLogsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/actualLogs2: } = await maybeMockConsolescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/maybeMockConsole().(validateLogs, () => |
| 322 |
babelscip-typescript npm @babel/core 7.20.12 src/`index.ts`/.transformAsync(inputCode, getOpts(actual)), |
| 323 |
)); |
| 324 |
|
| 325 |
const outputCode = normalizeOutputscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/normalizeOutput().(result.codescip-typescript npm @babel/core 7.20.12 src/transformation/`index.ts`/FileResult#typeLiteral44:code.); |
| 326 |
|
| 327 |
checkDuplicateNodesscip-typescript npm @babel/helper-check-duplicate-nodes 7.18.6 src/`index.ts`/checkDuplicateNodes().(result.astscip-typescript npm @babel/core 7.20.12 src/transformation/`index.ts`/FileResult#typeLiteral44:ast.); |
| 328 |
if (!ignoreOutput) { |
| 329 |
if ( |
| 330 |
!expected.codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code. && |
| 331 |
outputCode && |
| 332 |
!opts.throwsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#throws. && |
| 333 |
fs.statSync(path.dirname(expected.locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.)).isDirectory() && |
| 334 |
!process.env.CI |
| 335 |
) { |
| 336 |
const expectedFile = expected.locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc..replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().( |
| 337 |
/\.m?js$/, |
| 338 |
result.sourceTypescip-typescript npm @babel/core 7.20.12 src/transformation/`index.ts`/FileResult#typeLiteral44:sourceType. === "module" ? ".mjs" : ".js", |
| 339 |
); |
| 340 |
|
| 341 |
consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().(`New test file created: ${expectedFile}`); |
| 342 |
fs.writeFileSync(expectedFile, `${outputCode}\n`); |
| 343 |
|
| 344 |
if (expected.locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc. !== expectedFile) { |
| 345 |
try { |
| 346 |
fs.unlinkSync(expected.locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.); |
| 347 |
} catch (e) {} |
| 348 |
} |
| 349 |
} else { |
| 350 |
validateFilescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().(outputCode, expected.locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc., expectedCode); |
| 351 |
|
| 352 |
if (inputCode) { |
| 353 |
expect(expected.locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.).toMatch( |
| 354 |
result.sourceTypescip-typescript npm @babel/core 7.20.12 src/transformation/`index.ts`/FileResult#typeLiteral44:sourceType. === "module" ? /\.mjs$/ : /\.js$/, |
| 355 |
); |
| 356 |
} |
| 357 |
} |
| 358 |
} |
| 359 |
|
| 360 |
if (validateLogs) { |
| 361 |
validateFilescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().( |
| 362 |
normalizeOutputscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/normalizeOutput().(actualLogs.stdoutscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/stdout0:, /* normalizePathSeparator */ true), |
| 363 |
stdout.locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc., |
| 364 |
stdout.codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code., |
| 365 |
); |
| 366 |
validateFilescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().( |
| 367 |
normalizeOutputscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/normalizeOutput().(actualLogs.stderrscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/stderr0:, /* normalizePathSeparator */ true), |
| 368 |
stderr.locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc., |
| 369 |
stderr.codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code., |
| 370 |
); |
| 371 |
} |
| 372 |
} |
| 373 |
|
| 374 |
if (opts.sourceMapsscip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/ValidatedOptions#typeLiteral23:sourceMaps. === true) { |
| 375 |
try { |
| 376 |
expect(result.mapscip-typescript npm @babel/core 7.20.12 src/transformation/`index.ts`/FileResult#typeLiteral44:map.).toEqual(taskscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/run().(task).sourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMap.); |
| 377 |
} catch (e) { |
| 378 |
if (!process.env.OVERWRITE && taskscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/run().(task).sourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMap.) throw e; |
| 379 |
|
| 380 |
consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().(`Updated test file: ${taskscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/run().(task).sourceMapFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMapFile..locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.}`); |
| 381 |
fs.writeFileSync( |
| 382 |
taskscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/run().(task).sourceMapFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMapFile..locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc., |
| 383 |
JSONscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#.stringifyscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#stringify().(result.mapscip-typescript npm @babel/core 7.20.12 src/transformation/`index.ts`/FileResult#typeLiteral44:map., null, 2), |
| 384 |
); |
| 385 |
} |
| 386 |
} |
| 387 |
|
| 388 |
if (execCode && resultExec) { |
| 389 |
return resultExec; |
| 390 |
} |
| 391 |
} |
| 392 |
|
| 393 |
function validateFilescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().( |
| 394 |
actualCodescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().(actualCode): string, |
| 395 |
expectedLocscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().(expectedLoc): string, |
| 396 |
expectedCodescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().(expectedCode): string, |
| 397 |
) { |
| 398 |
try { |
| 399 |
expect(actualCodescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().(actualCode)).toEqualFile({ |
| 400 |
filenamescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/filename4:: expectedLocscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().(expectedLoc), |
| 401 |
codescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/code1:: expectedCodescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().(expectedCode), |
| 402 |
}); |
| 403 |
} catch (e) { |
| 404 |
if (!process.env.OVERWRITE) throw e; |
| 405 |
|
| 406 |
consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().(`Updated test file: ${expectedLocscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().(expectedLoc)}`); |
| 407 |
fs.writeFileSync(expectedLocscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().(expectedLoc), `${actualCodescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/validateFile().(actualCode)}\n`); |
| 408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
function escapeRegExpscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/escapeRegExp().(stringscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/escapeRegExp().(string): string) { |
| 412 |
return stringscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/escapeRegExp().(string).replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().(/[|\\{}()[\]^$+*?.]/g, "\\$&"); |
| 413 |
} |
| 414 |
|
| 415 |
function normalizeOutputscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/normalizeOutput().(codescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/normalizeOutput().(code): string, normalizePathSeparatorscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/normalizeOutput().(normalizePathSeparator)?: boolean) { |
| 416 |
const projectRoot = path.resolve( |
| 417 |
path.dirname(fileURLToPath(import.meta.urlscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/ImportMeta#url.)), |
| 418 |
"../../../", |
| 419 |
); |
| 420 |
const cwdSymbol = "<CWD>"; |
| 421 |
let result = codescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/normalizeOutput().(code) |
| 422 |
.trimscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#trim().() |
| 423 |
// (non-win32) /foo/babel/packages -> <CWD>/packages |
| 424 |
// (win32) C:\foo\babel\packages -> <CWD>\packages |
| 425 |
.replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().(new RegExpscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/RegExp#(escapeRegExpscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/escapeRegExp().(projectRoot), "g"), cwdSymbol); |
| 426 |
if (process.platform === "win32") { |
| 427 |
result = result |
| 428 |
// C:/foo/babel/packages -> <CWD>/packages |
| 429 |
.replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().( |
| 430 |
new RegExpscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/RegExp#(escapeRegExpscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/escapeRegExp().(projectRoot.replace(/\\/g, "/")), "g"), |
| 431 |
cwdSymbol, |
| 432 |
) |
| 433 |
// C:\\foo\\babel\\packages -> <CWD>\\packages (in js string literal) |
| 434 |
.replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().( |
| 435 |
new RegExpscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/RegExp#(escapeRegExpscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/escapeRegExp().(projectRoot.replace(/\\/g, "\\\\")), "g"), |
| 436 |
cwdSymbol, |
| 437 |
); |
| 438 |
if (normalizePathSeparatorscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/normalizeOutput().(normalizePathSeparator)) { |
| 439 |
result = result.replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().(/<CWD>[\w\\/.-]+/g, path => |
| 440 |
path.replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().(/\\\\?/g, "/"), |
| 441 |
); |
| 442 |
} |
| 443 |
} |
| 444 |
return result; |
| 445 |
} |
| 446 |
|
| 447 |
expect.extend({ |
| 448 |
toEqualFile(actual, { filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#filename., codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code. }: Pickscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Pick#<TestFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#, "filename" | "code">) { |
| 449 |
if (this.isNot) { |
| 450 |
throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(".toEqualFile does not support negation"); |
| 451 |
} |
| 452 |
|
| 453 |
const pass = actual === code; |
| 454 |
return { |
| 455 |
passscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/pass0:, |
| 456 |
messagescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/message0:: () => { |
| 457 |
const diffString = this.utils.diff(code, actual, { |
| 458 |
expandscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/expand0:: false, |
| 459 |
}); |
| 460 |
return ( |
| 461 |
`Expected ${filename} to match transform output.\n` + |
| 462 |
`To autogenerate a passing version of this file, delete the file and re-run the tests.\n\n` + |
| 463 |
`Diff:\n\n${diffString}` |
| 464 |
); |
| 465 |
}, |
| 466 |
}; |
| 467 |
}, |
| 468 |
}); |
| 469 |
|
| 470 |
declare globalscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/global/ { |
| 471 |
// eslint-disable-next-line no-redeclare,@typescript-eslint/no-unused-vars |
| 472 |
namespace jestscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/global/jest/ { |
| 473 |
// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 474 |
interface Matchersscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/global/jest/Matchers#<Rscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/global/jest/Matchers#[R]> { |
| 475 |
toEqualFilescip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/global/jest/Matchers#toEqualFile().({ |
| 476 |
filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#filename., |
| 477 |
codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code., |
| 478 |
}: Pickscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Pick#<TestFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#, "filename" | "code">): jestscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/global/jest/.CustomMatcherResult; |
| 479 |
} |
| 480 |
} |
| 481 |
} |
| 482 |
|
| 483 |
export type SuiteOptionsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/SuiteOptions# = { |
| 484 |
ignoreSuitesscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/SuiteOptions#typeLiteral186:ignoreSuites.?: string[]; |
| 485 |
ignoreTasksscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/SuiteOptions#typeLiteral186:ignoreTasks.?: string[]; |
| 486 |
}; |
| 487 |
|
| 488 |
export default function ( |
| 489 |
fixturesLoc: string, |
| 490 |
name: string, |
| 491 |
suiteOpts: SuiteOptionsscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/SuiteOptions# = {}, |
| 492 |
taskOpts: TaskOptionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions# = {}, |
| 493 |
dynamicOpts?: (options: TaskOptionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#, task: Testscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#) => void, |
| 494 |
) { |
| 495 |
const suites = getFixturesscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/get().(fixturesLoc); |
| 496 |
|
| 497 |
for (const testSuite of suites) { |
| 498 |
if (suiteOpts.ignoreSuitesscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/SuiteOptions#typeLiteral186:ignoreSuites.?.includesscip-typescript npm typescript 5.9.3 lib/`lib.es2016.array.include.d.ts`/Array#includes().(testSuite.titlescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite#typeLiteral6:title.)) continue; |
| 499 |
|
| 500 |
describe(name + "/" + testSuite.titlescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite#typeLiteral6:title., function () { |
| 501 |
for (const task of testSuite.testsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite#typeLiteral6:tests.) { |
| 502 |
if ( |
| 503 |
suiteOpts.ignoreTasksscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/SuiteOptions#typeLiteral186:ignoreTasks.?.includesscip-typescript npm typescript 5.9.3 lib/`lib.es2016.array.include.d.ts`/Array#includes().(task.titlescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#title.) || |
| 504 |
suiteOpts.ignoreTasksscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/SuiteOptions#typeLiteral186:ignoreTasks.?.includesscip-typescript npm typescript 5.9.3 lib/`lib.es2016.array.include.d.ts`/Array#includes().(testSuite.titlescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite#typeLiteral6:title. + "/" + task.titlescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#title.) |
| 505 |
) { |
| 506 |
continue; |
| 507 |
} |
| 508 |
|
| 509 |
const testFn = task.disabledscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#disabled. ? it.skip : it; |
| 510 |
|
| 511 |
testFn( |
| 512 |
task.titlescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#title., |
| 513 |
|
| 514 |
async function () { |
| 515 |
const runTask = () => runscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/run().(task); |
| 516 |
|
| 517 |
if ("sourceMap" in task.optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options.) { |
| 518 |
throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#( |
| 519 |
"`sourceMap` option is deprecated. Use `sourceMaps` instead.", |
| 520 |
); |
| 521 |
} |
| 522 |
|
| 523 |
if ("sourceMaps" in task.optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options. === false) { |
| 524 |
task.optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options..sourceMapsscip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/ValidatedOptions#typeLiteral23:sourceMaps. = !!task.sourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMap.; |
| 525 |
} |
| 526 |
|
| 527 |
Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.assignscip-typescript npm typescript 5.9.3 lib/`lib.es2015.core.d.ts`/ObjectConstructor#assign().(task.optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options., taskOpts); |
| 528 |
|
| 529 |
if (dynamicOpts) dynamicOpts(task.optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options., task); |
| 530 |
|
| 531 |
if (task.externalHelpersscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#externalHelpers.) { |
| 532 |
(task.optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options..pluginsscip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/ValidatedOptions#typeLiteral23:plugins. ??= []) |
| 533 |
// @ts-expect-error manipulating input options |
| 534 |
.push([ |
| 535 |
"external-helpers", |
| 536 |
{ helperVersionscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/helperVersion0:: EXTERNAL_HELPERS_VERSIONscip-typescript npm @babel/helper-transform-fixture-test-runner 7.20.14 src/`index.ts`/EXTERNAL_HELPERS_VERSION. }, |
| 537 |
]); |
| 538 |
} |
| 539 |
|
| 540 |
const throwMsg = task.optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options..throwsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#throws.; |
| 541 |
if (throwMsg) { |
| 542 |
// internal api doesn't have this option but it's best not to pollute |
| 543 |
// the options object with useless options |
| 544 |
delete task.optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options..throwsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#throws.; |
| 545 |
|
| 546 |
await assert.rejects(runTask, function (err: Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#) { |
| 547 |
assert.ok( |
| 548 |
throwMsg === true || err.messagescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#message..includesscip-typescript npm typescript 5.9.3 lib/`lib.es2015.core.d.ts`/String#includes().(throwMsg), |
| 549 |
` |
| 550 |
Expected Error: ${throwMsg} |
| 551 |
Actual Error: ${err.messagescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#message.}`, |
| 552 |
); |
| 553 |
return true; |
| 554 |
}); |
| 555 |
} else { |
| 556 |
return runTask(); |
| 557 |
} |
| 558 |
}, |
| 559 |
); |
| 560 |
} |
| 561 |
}); |
| 562 |
} |
| 563 |
} |