mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
0ea72807a6
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41314 Changelog: [Internal] Adds the beginning of a test suite for `inspector-proxy`. For maintainability, we only test functionality exposed from the `dev-middleware` boundary rather than instantiating `InspectorProxy` directly. In this diff, the test coverage is far from complete, but this is a first stab at covering some basics. `InspectorProxyHttpApi-test` exercises the HTTP GET endpoints (`/json/list` and `/json/version`) as well as some device registration logic through the `/inspector/device` WebSocket. Some reusable helpers for server setup and device mocking are included in separate files. As an overall strategy, I'm planning to add multiple test files that share helpers between them, not build out one massive test file with all the helpers inline. There will likely be some verbose tests when we start covering debugger-to-device communication, and I want to keep them as readable as possible. Reviewed By: blakef Differential Revision: D50980467 fbshipit-source-id: 962dae5a380451d6dac57eac23c4436550a39cf8
33 lines
827 B
JavaScript
33 lines
827 B
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
* @oncall react_native
|
|
*/
|
|
|
|
export function withAbortSignalForEachTest(): $ReadOnly<{signal: AbortSignal}> {
|
|
const ref: {signal: AbortSignal} = {
|
|
// $FlowIgnore[unsafe-getters-setters]
|
|
get signal() {
|
|
throw new Error(
|
|
'The return value of withAbortSignalForEachTest is lazily initialized and can only be accessed in tests.',
|
|
);
|
|
},
|
|
};
|
|
let controller;
|
|
beforeEach(() => {
|
|
controller = new AbortController();
|
|
Object.defineProperty(ref, 'signal', {
|
|
value: controller.signal,
|
|
});
|
|
});
|
|
afterEach(() => {
|
|
controller.abort();
|
|
});
|
|
return ref;
|
|
}
|