MCPcopy
hub / github.com/vercel/next.js / describe

Function describe

turbopack/packages/devlow-bench/src/describe.ts:16–63  ·  view source on GitHub ↗
(
  name: string,
  config: ConfigFor<P>,
  fn: (props: P) => Promise<void>
)

Source from the content-addressed store, hash-verified

14}
15
16export function describe<P>(
17 name: string,
18 config: ConfigFor<P>,
19 fn: (props: P) => Promise<void>
20): void {
21 if (currentScenarios === null) {
22 const scenarios = (currentScenarios = [])
23
24 Promise.resolve().then(async () => {
25 const ifaceNames = process.env.INTERFACE || 'interactive,console'
26 const ifaces = []
27 for (const ifaceName of ifaceNames.split(',').map((s) => s.trim())) {
28 let iface: unknown
29 try {
30 iface = await import(`./interfaces/${ifaceName}.js`)
31 } catch (e) {
32 iface = await import(ifaceName)
33 }
34 iface = (iface && (iface as any).default) || iface
35 if (typeof iface === 'function') {
36 iface = await iface()
37 }
38 if (!iface) {
39 throw new Error(`Interface ${ifaceName} is not a valid interface`)
40 }
41 ifaces.push(iface as Interface)
42 }
43 runScenarios(scenarios, compose(...ifaces))
44 })
45 }
46 const normalizedConfig: Record<string, (string | number | boolean)[]> =
47 Object.fromEntries(
48 Object.entries(config).map(([key, value]) => [
49 key,
50 typeof value === 'boolean'
51 ? [value, !value]
52 : (value as (string | number | boolean)[]),
53 ])
54 )
55 currentScenarios!.push({
56 name,
57 config: normalizedConfig,
58 only: false,
59 fn: fn as (
60 props: Record<string, string | number | boolean>
61 ) => Promise<void>,
62 })
63}
64
65describe.only = function describeOnly<P>(
66 name: string,

Calls 9

runScenariosFunction · 0.85
thenMethod · 0.80
splitMethod · 0.80
trimMethod · 0.80
resolveMethod · 0.65
pushMethod · 0.65
composeFunction · 0.50
mapMethod · 0.45
entriesMethod · 0.45

Tested by

no test coverage detected