question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A redux-connected component being translated into ConnectFunction ?

See original GitHub issue

I have a failed unit test as below

  it('contains a wallet component', () => {
    console.log(app.debug());
    expect(app.find('Connect(Wallet)').exists()).toBe(true);
  });

Wallet.js

...

export class Wallet extends Component {
  ...
}

export default connect(state => ({ balance: state }))(Wallet);

App.js

import React, { Component } from 'react'
import Wallet from './Wallet';

class App extends Component {
  render() {
    return (
    <div>
      <h2>Loot Check</h2>
      <hr />
      <Wallet />
    </div>)
  }
}

export default App;

And below is the result of console.log(app.debug())

console.log src/components/App.test.js:13
      <div>
        <h2>
          Loot Check
        </h2>
        <hr />
        <ConnectFunction />
      </div>

I don’t understand, why a redux-connected component being turned into ConnectFunction?

API

  • shallow
  • mount
  • render

Version

library version
enzyme ^3.9.0
react ^16.8.6
react-dom ^16.8.6
react-test-renderer
adapter (below) 1.12.1

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-16.3
  • enzyme-adapter-react-16.2
  • enzyme-adapter-react-16.1
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
ljharbcommented, Apr 26, 2019

react-redux 6 and 7 won’t work properly with enzyme until the next enzyme release.

6reactions
vernak2539commented, Jun 4, 2019

Just a note, you’ll have to upgrade enzyme-adapter-react-16 as well

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Redux connect(): When and how to use it
Cover when and how to use the React Redux connect() API to create container components that are connected to the Redux state.
Read more >
Problems accessing Connect function value in another ...
Problems accessing Connect function value in another Component in a React-Redux App ; Can you show us how and where you use Cart...
Read more >
Connect | React Redux
The connect() function connects a React component to a Redux store. It provides its connected component with the pieces of the data it...
Read more >
React Tips — Mock React-Redux, Internationalization, and ...
How to Unit Test React-Redux Connected Components. We can test a React-Redux connected component by mocking the connect function and Provider ...
Read more >
React-Redux - Level Up Coding - gitconnected
The connect() function connects a React component to a Redux store. ... function and by convention, it will be the first parameter of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found