MCPcopy
hub / github.com/jestjs/jest / execute

Method execute

packages/jest-jasmine2/src/jasmine/Spec.ts:176–217  ·  view source on GitHub ↗
(onComplete?: () => void, enabled?: boolean)

Source from the content-addressed store, hash-verified

174 }
175
176 execute(onComplete?: () => void, enabled?: boolean) {
177 // eslint-disable-next-line @typescript-eslint/no-this-alias
178 const self = this;
179
180 this.onStart(this);
181
182 if (
183 !this.isExecutable() ||
184 this.markedPending ||
185 this.markedTodo ||
186 enabled === false
187 ) {
188 complete(enabled);
189 return;
190 }
191
192 const fns = this.beforeAndAfterFns();
193 const allFns = fns.befores.concat(this.queueableFn).concat(fns.afters);
194
195 this.currentRun = this.queueRunnerFactory({
196 queueableFns: allFns,
197 onException() {
198 // @ts-expect-error: wrong context
199 self.onException.apply(self, arguments);
200 },
201 userContext: this.userContext(),
202 setTimeout,
203 clearTimeout,
204 fail: () => {},
205 });
206
207 this.currentRun.then(() => complete(true));
208
209 function complete(enabledAgain?: boolean) {
210 self.result.status = self.status(enabledAgain);
211 self.resultCallback(self.result);
212
213 if (onComplete) {
214 onComplete();
215 }
216 }
217 }
218
219 cancel() {
220 if (this.currentRun) {

Callers 4

jasmine2Function · 0.45
onRunCompleteMethod · 0.45
mapCoverage.mjsFile · 0.45

Calls 6

isExecutableMethod · 0.95
onStartMethod · 0.80
beforeAndAfterFnsMethod · 0.80
queueRunnerFactoryMethod · 0.80
userContextMethod · 0.80
thenMethod · 0.80

Tested by

no test coverage detected