Spec.d.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. */
  8. import { Config } from '@jest/types';
  9. import { FailedAssertion, Milliseconds, Status } from '@jest/test-result';
  10. import ExpectationFailed from '../ExpectationFailed';
  11. import expectationResultFactory, { Options as ExpectationResultFactoryOptions } from '../expectationResultFactory';
  12. import queueRunner, { QueueableFn } from '../queueRunner';
  13. import { AssertionErrorWithStack } from '../types';
  14. export declare type Attributes = {
  15. id: string;
  16. resultCallback: (result: Spec['result']) => void;
  17. description: string;
  18. throwOnExpectationFailure: unknown;
  19. getTestPath: () => Config.Path;
  20. queueableFn: QueueableFn;
  21. beforeAndAfterFns: () => {
  22. befores: Array<QueueableFn>;
  23. afters: Array<QueueableFn>;
  24. };
  25. userContext: () => unknown;
  26. onStart: (context: Spec) => void;
  27. getSpecName: (spec: Spec) => string;
  28. queueRunnerFactory: typeof queueRunner;
  29. };
  30. export declare type SpecResult = {
  31. id: string;
  32. description: string;
  33. fullName: string;
  34. duration?: Milliseconds;
  35. failedExpectations: Array<FailedAssertion>;
  36. testPath: Config.Path;
  37. passedExpectations: Array<ReturnType<typeof expectationResultFactory>>;
  38. pendingReason: string;
  39. status: Status;
  40. __callsite?: {
  41. getColumnNumber: () => number;
  42. getLineNumber: () => number;
  43. };
  44. };
  45. export default class Spec {
  46. id: string;
  47. description: string;
  48. resultCallback: (result: SpecResult) => void;
  49. queueableFn: QueueableFn;
  50. beforeAndAfterFns: () => {
  51. befores: Array<QueueableFn>;
  52. afters: Array<QueueableFn>;
  53. };
  54. userContext: () => unknown;
  55. onStart: (spec: Spec) => void;
  56. getSpecName: (spec: Spec) => string;
  57. queueRunnerFactory: typeof queueRunner;
  58. throwOnExpectationFailure: boolean;
  59. initError: Error;
  60. result: SpecResult;
  61. disabled?: boolean;
  62. currentRun?: ReturnType<typeof queueRunner>;
  63. markedTodo?: boolean;
  64. markedPending?: boolean;
  65. expand?: boolean;
  66. static pendingSpecExceptionMessage: string;
  67. static isPendingSpecException(e: Error): boolean;
  68. constructor(attrs: Attributes);
  69. addExpectationResult(passed: boolean, data: ExpectationResultFactoryOptions, isError?: boolean): void;
  70. execute(onComplete: Function, enabled: boolean): void;
  71. cancel(): void;
  72. onException(error: ExpectationFailed | AssertionErrorWithStack): void;
  73. disable(): void;
  74. pend(message?: string): void;
  75. todo(): void;
  76. getResult(): SpecResult;
  77. status(enabled?: boolean): "disabled" | "pending" | "failed" | "passed" | "todo";
  78. isExecutable(): boolean;
  79. getFullName(): string;
  80. isAssertionError(error: Error): boolean;
  81. }
  82. //# sourceMappingURL=Spec.d.ts.map