Function tsJestConvertExportNameString

  • Converts the name of an exported function or variable in a Jest test suite to use the .name property of the exported item. This is useful for keeping test suite names in sync with the names of the items they are testing.

    Parameters

    • code: string

      The source code of the Jest test suite.

    • funName: string

      The name of the function being tested.

    Returns string

    The modified source code.

    Example

    const code = `describe('myFunction', () => {...})`;
    const exportName = 'myFunction';
    const newCode = tsJestConvertExportNameString(code, exportName);
    //=> `describe(myFunction.name, () => {...})`

Generated using TypeDoc