Enzyme: Ability to set global rendering options for shallow

Created on 4 Oct 2017  路  5Comments  路  Source: enzymejs/enzyme

After upgrading to V3 the new default value for options.lifecycleExperimental causes a few of my tests to fail due to calls I'm making in componentDidMount that assumes I have a DOM.

When I want to make more extensive tests I use mount and expect lifecycle methods like componentDidMount to be called.

It would be great if I could set global options for shallow rendering - in my case I would set options. disableLifecycleMethods = true

mount shallow feature request

Most helpful comment

Currently, we can set disableLifecycleMethods option only with calling shallow method.
I think it makes to be able to set disableLifecycleMethods option with calling configure.

Enzyme.configure({
  adapter: new Adapter(),
  // it should be a explicit name indicating to affect only `shallow`
  disableLifecycleMethods: true
});

All 5 comments

I believe you can set that globally in the configure call?

Currently, we can set disableLifecycleMethods option only with calling shallow method.
I think it makes to be able to set disableLifecycleMethods option with calling configure.

Enzyme.configure({
  adapter: new Adapter(),
  // it should be a explicit name indicating to affect only `shallow`
  disableLifecycleMethods: true
});

Ah, thanks for clarifying.

I think we'd want a namespace specifically for both shallow and mount options (and render if applicable)?

@ljharb 馃憤 That's reasonable to me.

Hmm - this already seems like it's implemented, in that all options passed to configure are merged with options passed to the ShallowWrapper and ReactWrapper constructors.

I'm going to close, but will reopen if this isn't sufficient.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blainekasten picture blainekasten  路  3Comments

dschinkel picture dschinkel  路  3Comments

blainekasten picture blainekasten  路  3Comments

AdamYahid picture AdamYahid  路  3Comments

rexonms picture rexonms  路  3Comments