Files
react-native/packages/polyfills/__tests__/consoleTimeStamp-itest.js
Ruslan LesiutinandFacebook GitHub Bot c612ae424a @react-native/js-polyfills: polyfill console.timeStamp (#52168)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52168

# Changelog: [Internal]

The main reason for the stub is to make sure this method is always installed. The actual implementation will be part of the `jsinspector-modern` stack, which is fully initialized in production builds.

Once there is a gurantee that RuntimeTarget globals are always installed in any environments, we can remove polyfills altogether.

Reviewed By: rubennorte, GijsWeterings

Differential Revision: D76987507

fbshipit-source-id: 2602af28f9e4359cf58dfafdf84802c0bf92372d
2025-06-26 05:25:09 -07:00

42 lines
1.2 KiB
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
* @fantom_mode *
* @fantom_flags fuseboxEnabledRelease:*
*/
describe('console.timeStamp()', () => {
it('installed', () => {
expect(typeof console.timeStamp).toBe('function');
});
it("doesn't throw when label is not specified", () => {
expect(() => console.timeStamp()).not.toThrow();
});
it("doesn't throw when label is specified", () => {
expect(() => console.timeStamp('label')).not.toThrow();
});
it("doesn't throw when additional arguments are specified", () => {
expect(() =>
// $FlowExpectedError[extra-arg]
console.timeStamp('label', 100, 500, 'Track', 'Group', 'error'),
).not.toThrow();
});
it("doesn't throw when invalid arguments are specified", () => {
// $FlowExpectedError[incompatible-call]
expect(() => console.timeStamp({})).not.toThrow();
expect(() =>
// $FlowExpectedError[extra-arg]
console.timeStamp('label', true, null, {}, [], () => {}),
).not.toThrow();
});
});