MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / getCodeSuggestions

Method getCodeSuggestions

lib/heal.js:55–91  ·  view source on GitHub ↗
(context)

Source from the content-addressed store, hash-verified

53 }
54
55 async getCodeSuggestions(context) {
56 const suggestions = []
57 const stepName = context.step?.title
58 const recipes = matchRecipes(this.recipes, this.contextName)
59 .filter(r => !r.steps || !stepName || r.steps.includes(stepName))
60
61 debug('Recipes', recipes)
62
63 const currentOutputLevel = output.level()
64 output.level(0)
65
66 for (const [property, prepareFn] of Object.entries(
67 recipes
68 .map(r => r.prepare)
69 .filter(p => !!p)
70 .reduce((acc, obj) => ({ ...acc, ...obj }), {}),
71 )) {
72 if (!prepareFn) continue
73
74 if (context[property]) continue
75 context[property] = await prepareFn(container.support())
76 }
77
78 output.level(currentOutputLevel)
79
80 for (const recipe of recipes) {
81 let snippets = await recipe.fn(context)
82 if (!Array.isArray(snippets)) snippets = [snippets]
83
84 suggestions.push({
85 name: recipe.name,
86 snippets,
87 })
88 }
89
90 return suggestions.filter(s => !isBlank(s.snippets))
91 }
92
93 async healStep(failedStep, error, failureContext = {}) {
94 output.debug(`Trying to heal ${failedStep.toCode()} step`)

Callers 2

healStepMethod · 0.95
heal_test.jsFile · 0.80

Calls 8

matchRecipesFunction · 0.85
debugFunction · 0.85
isBlankFunction · 0.85
filterMethod · 0.80
includesMethod · 0.80
entriesMethod · 0.80
supportMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected