index.d.ts 1.0 KB

123456789101112131415161718192021222324252627282930
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. /// <reference types="node" />
  8. import { Context, Script } from 'vm';
  9. import type { JestEnvironment } from '@jest/environment';
  10. import { LegacyFakeTimers, ModernFakeTimers } from '@jest/fake-timers';
  11. import type { Config, Global } from '@jest/types';
  12. import { ModuleMocker } from 'jest-mock';
  13. declare type Timer = {
  14. id: number;
  15. ref: () => Timer;
  16. unref: () => Timer;
  17. };
  18. declare class NodeEnvironment implements JestEnvironment {
  19. context: Context | null;
  20. fakeTimers: LegacyFakeTimers<Timer> | null;
  21. fakeTimersModern: ModernFakeTimers | null;
  22. global: Global.Global;
  23. moduleMocker: ModuleMocker | null;
  24. constructor(config: Config.ProjectConfig);
  25. setup(): Promise<void>;
  26. teardown(): Promise<void>;
  27. runScript<T = unknown>(script: Script): T | null;
  28. getVmContext(): Context | null;
  29. }
  30. export = NodeEnvironment;