Type alias EngineType<Queries, Wrappers, FireEvents, Scenarios>

EngineType<Queries, Wrappers, FireEvents, Scenarios>: Readonly<{
    accessors: {
        [Key in keyof Queries]: AccessorsType
    };
    fireEvent: ((eventKey, options?) => void);
    qs: RenderResult;
    run: (<Key>(scenarioKey, ...args) => Promise<void>);
    wrappers: {
        [Key in keyof Wrappers]: ReturnType<Wrappers[Key]>[1]
    };
}>

Type Parameters

  • Queries extends Record<string, AccessorParamsType>

  • Wrappers extends Record<string, WrapperType<any, any>>

  • FireEvents extends Record<string, [keyof Queries, EventType]>

  • Scenarios extends Record<string, [keyof Queries, ((element, ...args) => Promise<void>)]>

Type declaration

  • accessors: {
        [Key in keyof Queries]: AccessorsType
    }

    An object whose keys are keys of the queries parameter and whose values are accessors (see AccessorsType)

    const render = create(Component, defaultProps, {
    queries: {
    listItem: {
    query: AccessorQueryType.LabelText,
    parameters: ["the item of the list"],
    },

    navigation: {
    query: AccessorQueryType.Role,
    parameters: ["navigation"],
    },
    },
    });

    const engine = render({});

    const listItems = page.accessors.listItem.getAll();
    const navigation = page.accessors.navigation.get();
  • fireEvent: ((eventKey, options?) => void)
      • (eventKey, options?): void
      • Fire an event in act wrapper

        Parameters

        • eventKey: keyof FireEvents

          a key of the fireEvents parameter

        • Optional options: {}

          optional, an event object

          Returns void

          Throws

          if fireEvents is not provided

          const render = create(Component, defaultProps, {
          queries: {
          button: {
          query: AccessorQueryType.Text,
          parameters: ["Click me"],
          },
          },

          fireEvents: {
          buttonClick: ["button", "click"],
          },
          });

          const engine = render({});

          engine.fireEvent("buttonClick");
    • qs: RenderResult

      Result of render of @testing-library/react

    • run: (<Key>(scenarioKey, ...args) => Promise<void>)
        • <Key>(scenarioKey, ...args): Promise<void>
        • Run scenario by key, see scenarios property of options

          Type Parameters

          • Key extends keyof Scenarios

          Parameters

          • scenarioKey: Key

            key of scenarios option

          • Rest ...args: RunScenatioParameters<Scenarios[Key][1]>

            scenario arguments

          Returns Promise<void>

    • wrappers: {
          [Key in keyof Wrappers]: ReturnType<Wrappers[Key]>[1]
      }

      An object whose keys are keys of wrappers from options, and values are results of wrappers

      A rough example:

      const AwesomeContext = createContext(0);

      const render = create(Component, defaultProps, {
      queries: {},

      wrappers: {
      awesome: (children, initialValue) => {
      let value = initialValue;

      const getActualValue = () => value;

      return [
      <AwesomeContext.Provider value={value}>
      {children}
      </AwesomeContext.Provider>,
      getActualValue,
      ];
      },
      },

      wrapperDefaultParams: {
      awesome: 0,
      },
      });

      const engine = render({}, {
      wrapperParams: {
      awesome: 3,
      },
      });

      const awesomeValue = engine.wrappers.awesome();

      See an example https://github.com/vtaits/react-integration-test-engine/blob/main/packages/react-integration-test-engine/src/tests/wrappers.test.tsx

    Generated using TypeDoc