Skip to content

Commit

Permalink
rCemoved the UNSTABLE_prefix & resolved usages
Browse files Browse the repository at this point in the history
  • Loading branch information
kunal-kushwaha committed Jul 28, 2020
1 parent 6ffa6ae commit 9296d86
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
29 changes: 12 additions & 17 deletions packages/jest-runner/src/index.ts
Expand Up @@ -49,7 +49,7 @@ namespace TestRunner {
class TestRunner {
private readonly _globalConfig: Config.GlobalConfig;
private readonly _context: JestTestRunnerContext;
private readonly UNSTABLE_eventEmitter = new Emittery.Typed<JestTestEvents>();
private readonly eventEmitter = new Emittery.Typed<JestTestEvents>();
readonly __PRIVATE_UNSTABLE_API_supportsEventEmitters__: boolean = true;

readonly isSerial?: boolean;
Expand Down Expand Up @@ -109,35 +109,33 @@ class TestRunner {
this._globalConfig,
test.context.config,
test.context.resolver,
undefined,
this._context,
undefined,
);
} else {
// `deepCyclicCopy` used here to avoid mem-leak
sendMessageToJest = (eventName, args) =>
this.UNSTABLE_eventEmitter.emit(
this.eventEmitter.emit(
eventName,
deepCyclicCopy(args, {keepPrototype: false}),
);

await this.UNSTABLE_eventEmitter.emit('test-file-start', [
test,
]);
await this.eventEmitter.emit('test-file-start', [test]);
return runTest(
test.path,
this._globalConfig,
test.context.config,
test.context.resolver,
sendMessageToJest,
this._context,
sendMessageToJest,
);
}
})
.then(result => {
if (onResult) {
return onResult(test, result);
} else {
return this.UNSTABLE_eventEmitter.emit('test-file-success', [
return this.eventEmitter.emit('test-file-success', [
test,
result,
]);
Expand All @@ -147,10 +145,7 @@ class TestRunner {
if (onFailure) {
return onFailure(test, err);
} else {
return this.UNSTABLE_eventEmitter.emit('test-file-failure', [
test,
err,
]);
return this.eventEmitter.emit('test-file-failure', [test, err]);
}
}),
),
Expand Down Expand Up @@ -204,7 +199,7 @@ class TestRunner {
if (onStart) {
await onStart(test);
} else {
await this.UNSTABLE_eventEmitter.emit('test-file-start', [test]);
await this.eventEmitter.emit('test-file-start', [test]);
}

const promise = worker.worker({
Expand All @@ -225,7 +220,7 @@ class TestRunner {
if (promise.UNSTABLE_onCustomMessage) {
// TODO: Get appropriate type for `onCustomMessage`
promise.UNSTABLE_onCustomMessage(([event, payload]: any) => {
this.UNSTABLE_eventEmitter.emit(event, payload);
this.eventEmitter.emit(event, payload);
});
}

Expand All @@ -237,7 +232,7 @@ class TestRunner {
if (onFailure) {
await onFailure(test, err);
} else {
await this.UNSTABLE_eventEmitter.emit('test-file-failure', [test, err]);
await this.eventEmitter.emit('test-file-failure', [test, err]);
}
if (err.type === 'ProcessTerminatedError') {
console.error(
Expand All @@ -263,7 +258,7 @@ class TestRunner {
if (onResult) {
return onResult(test, result);
} else {
return this.UNSTABLE_eventEmitter.emit('test-file-success', [
return this.eventEmitter.emit('test-file-success', [
test,
result,
]);
Expand All @@ -288,7 +283,7 @@ class TestRunner {
return Promise.race([runAllTests, onInterrupt]).then(cleanup, cleanup);
}

on = this.UNSTABLE_eventEmitter.on.bind(this.UNSTABLE_eventEmitter);
on = this.eventEmitter.on.bind(this.eventEmitter);
}

class CancelRun extends Error {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-runner/src/runTest.ts
Expand Up @@ -314,8 +314,8 @@ export default async function runTest(
globalConfig: Config.GlobalConfig,
config: Config.ProjectConfig,
resolver: ResolverType,
sendMessageToJest?: TestFileEvent,
context?: TestRunnerContext,
sendMessageToJest?: TestFileEvent,
): Promise<TestResult> {
const {leakDetector, result} = await runTestInternal(
path,
Expand Down

0 comments on commit 9296d86

Please sign in to comment.