jest-facade.d.ts 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { JestCliRunner, JestPreprocessor, JestPresetConfig, JestPuppeteerEnvironmentConstructor, JestScreenshotRunner, JestTestRunnerConstructor } from './jest-apis';
  2. /**
  3. * Interface for Jest-version specific code implementations that interact with Stencil.
  4. *
  5. * It is expected that there exists a Jest version-specific implementation for this interface in each version-specific
  6. * directory Stencil supports.
  7. */
  8. export interface JestFacade {
  9. /**
  10. * Retrieve a function that invokes the Jest CLI.
  11. *
  12. * This function does not perform the invocation itself. Rather, it expects the caller to prepare a Stencil
  13. * configuration object and environment for tests to run and invoke the returned value itself.
  14. *
  15. * @returns A function that invokes the Jest CLI.
  16. */
  17. getJestCliRunner(): JestCliRunner;
  18. /**
  19. * Retrieve a function that invokes Stencil's Screenshot runner.
  20. *
  21. * This function does not start screenshot tests themselves. Rather, it expects the caller to prepare a Stencil
  22. * configuration object and environment for tests to run and invoke the screenshot runner itself.
  23. *
  24. * @returns A function that invokes the Screenshot runner.
  25. */
  26. getRunJestScreenshot(): JestScreenshotRunner;
  27. /**
  28. * Retrieve the default Jest runner name prescribed by Stencil.
  29. *
  30. * Examples of valid return values include 'jest-jasmine2' and 'jest-circus'.
  31. *
  32. * @returns the stringified name of the test runner, based on the currently detected version of Stencil
  33. */
  34. getDefaultJestRunner(): string;
  35. /**
  36. * Retrieve a function that builds an E2E (puppeteer) testing environment that uses Jest as its test runner.
  37. *
  38. * @returns A function that builds an E2E testing environment.
  39. */
  40. getCreateJestPuppeteerEnvironment(): () => JestPuppeteerEnvironmentConstructor;
  41. /**
  42. * Create an object used to transform files as a part of running Jest.
  43. *
  44. * The object returned by this function is expected to conform to the interface/guide laid out by Jest for
  45. * [writing custom transformers](https://jestjs.io/docs/code-transformation#writing-custom-transformers).
  46. *
  47. * @returns the object used to transform files at test time
  48. */
  49. getJestPreprocessor(): JestPreprocessor;
  50. /**
  51. * Retrieve a function that returns the custom Stencil-Jest test runner
  52. *
  53. * @returns a function that retrieves the test runner
  54. */
  55. getCreateJestTestRunner(): () => JestTestRunnerConstructor;
  56. /**
  57. * Retrieve a function that returns the setup configuration code to run between tests.
  58. *
  59. * The value returned by said function is expected to be used in a
  60. * [setupFilesAfterEnv](https://jestjs.io/docs/configuration#setupfilesafterenv-array) context.
  61. *
  62. * @returns a function that runs a setup configuration between tests.
  63. */
  64. getJestSetupTestFramework(): () => void;
  65. /**
  66. * Retrieve the Jest preset configuration object for configuring tests.
  67. *
  68. * The value returned by said function is expected to be used in a
  69. * [preset](https://jestjs.io/docs/configuration#preset-string) context.
  70. *
  71. * @returns the Jest preset object to be used for a particular version of Jest.
  72. */
  73. getJestPreset(): JestPresetConfig;
  74. }