UNPKG

jest-mock-action-creators

Version:

Easy mock & test redux action creators with dispatch() in your components

37 lines (36 loc) 1 kB
import * as b from "@babel/core"; import * as t from "@babel/types"; import * as bt from "@babel/traverse"; export interface PluginOptions { /** * Global jest identifier */ jestIdentifier: string; /** * Require identifier */ requireIdentifier: string; /** * List of call expressions to ignore them for auto-mocking */ mockIgnoreExpressions: string[]; } export interface PluginState { /** * Mock action creators function name. It can be renamed during imports, for example */ mockActionCreatorsName: string; /** * All import identifiers with local value => source name */ importIdentifiers: Map<string, string>; /** * Existing jest mocks or already mocked action creators */ existingJestMocks: string[]; /** * Top-level program instance */ program: bt.NodePath<t.Program>; } export default function plugin({types: t}: typeof b, options?: PluginOptions): b.PluginObj<PluginState>;