Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero documentation for configure() options #2533

Open
3 tasks done
dPowNextdoor opened this issue Aug 9, 2021 · 5 comments
Open
3 tasks done

Zero documentation for configure() options #2533

dPowNextdoor opened this issue Aug 9, 2021 · 5 comments

Comments

@dPowNextdoor
Copy link

dPowNextdoor commented Aug 9, 2021

Current behavior

No resources anywhere show how to configure Enzyme outside of configure({ adapter: new MyAdapter() }), including the home page, GitHub ReadMe, test library guides, and adapter guides.

There are clearly ways to configure enzyme and adapters, but it's not clear if they should be done via:

  1. configure({ adapter: new MyAdapter({ ...myOptions )) })
  2. configure({ adapter: new MyAdapter(), ...myOptions })
  3. configure({ adapter: new MyAdapter({ ...someOptions }), ...otherOptions })

Expected behavior

Each and every function, especially those with configurable options and even more especially those created by the enzyme team itself, to be documented. We should be able to see pages like

Configure enzyme like this

configure({
    optName: type || [ validOptValue1, validOptValue2, ...],
    // ...
})

and

Configure enzyme adapters like this

configure({
    adapter: new Adapter({
        optName: type || [ validOptValue1, validOptValue2, ...],
        // ...
    }),
    // or alternatively here, who knows right now, it's not documented anywhere!
})

and

Configure enzyme-adapter-react-16 like this

configure({
    adapter: new Adapter({
        react16SpecificOption: type || [ validOptValue1, validOptValue2, ...],
        // ...
    }),
    // or alternatively here, who knows right now, it's not documented anywhere!
})

Example

FWIW, what I wanted to do was to change enzyme-adapter-react-16's getSnapshotBeforeUpdate to false so it waits for updates before taking snapshots, globally, for every test (suite).

Your environment

API

  • shallow
  • mount
  • render

Version

library version
enzyme 3.11.0, also tried 3.10.0
react 16.13.1
react-dom 16.13.1
react-test-renderer 16.13.1
enzyme-adapter-react-16 1.15.6, also tried 1.14.0
@ljharb
Copy link
Member

ljharb commented Aug 9, 2021

Other than adapter, they're the same options you'd pass to mount or shallow.

A PR making this clearer in the docs would be appreciated.

@dPowNextdoor
Copy link
Author

dPowNextdoor commented Aug 10, 2021

You brought up a good point. Is that true, that there is no way to configure enzyme/adapters?

I just updated my issue description, the gist being that I wanted to change one of the settings in an adapter that was (dare I say, "clearly?") marked as an entry in this.options, but do so globally for all tests in one place (the configure() call).

@ljharb
Copy link
Member

ljharb commented Aug 10, 2021

I’m not sure what you mean by “no way to configure” - the adapter generally decides what configuration options it takes.

@dPowNextdoor
Copy link
Author

Sorry, "no way to configure" was in response to:

Other than adapter, they're the same options you'd pass to mount or shallow.

Basically I was just asking for clarification on this. Did you mean there is no way to configure adapter-specific options depending on their usage/internal logic or is there actually a way, it's just not documented?

i.e. Only accepting the same mount/shallow options as any other adapter means I can't configure the React-specific getSnapshotBeforeUpdate or setState.skipsComponentDidUpdateOnNullish options.

@ljharb
Copy link
Member

ljharb commented Aug 15, 2021

Of course you can - each adapter can accept any options it wants, and do anything it likes with them.

All of the official adapters peel off the adapter-specific options and pass the rest into shallow/mount.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants