Nested components testing with Enzyme inside of React & Redux

后端 未结 6 1111
甜味超标
甜味超标 2020-12-24 05:55

I have a component SampleComponent that mounts another \"connected component\" (i.e. container). When I try to test SampleComponent by

6条回答
  •  一向
    一向 (楼主)
    2020-12-24 06:43

    in an attempt to make the use of decorator syntax more testable I made this: https://www.npmjs.com/package/babel-plugin-undecorate

    input:

    @anyOldClassDecorator
    export class AnyOldClass {
      @anyOldMethodDecorator
      method() {
        console.log('hello');   
      }
    }
    

    output:

    @anyOldClassDecorator
    export class AnyOldClass {
      @anyOldMethodDecorator
      method() {
        console.log('hello');   
      }
    }
    
    export class __undecorated__AnyOldClass {
      method() {
        console.log('hello');   
      }
    }
    

    Hopefully this can provide a solid Option 3!

提交回复
热议问题