简体   繁体   中英

How to mock/consider javascript prototype functions by default in jest test cases

The following code throws error as : TypeError: Cannot read property 'trim' of undefined

      this.setState({
        details: {
          ...this.state.details,
          [classificationType]: [value.trim()]
        }
      });

How to improve jest test cases to consider string features?

Might be you are not getting value that's why it is unable to read trim() function on that. Can you please explain from where you are getting value ? What mock data you used to execute your test case?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM