Mocking moment() and moment().format using jest

后端 未结 7 2100
暗喜
暗喜 2021-02-12 19:46

I\'m unable to mock moment() or moment().format functions. I have states where, currentDateMoment and currentDateFormatted ar

7条回答
  •  无人及你
    2021-02-12 20:39

    Don't use import * as moment from 'moment';

    Use the default import

    import moment from 'moment';
    
    // tsconfig.json
    { 
      "compilerOptions": {
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
      }
    }
    

    read

提交回复
热议问题