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

react-test-renderer and refs #7740

Closed
armandabric opened this issue Sep 15, 2016 · 19 comments
Closed

react-test-renderer and refs #7740

armandabric opened this issue Sep 15, 2016 · 19 comments
Assignees

Comments

@armandabric
Copy link

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
It's not possible to test component that use ref with the react-test-renderer utilitiesTesting: the refs are always null.

/* @flow */

import React from 'react';

export default class Foo extends React.Component {    
    /* the future refs */
    bar; 

    componentDidMount() {
        console.log(this.bar); // this.bar is null

        this.bar.doThings() // So this fail
    }

    render() {
        return (
            <div ref={(c) => { console.log('ref cb', c); this.bar = c; }}> {/* The callback is call but, `c` is null*/}
                <p>Hello World</p>
            </div>
        );
    }
}
import React from 'react';
import renderer from 'react-test-renderer';

it('should have valide ref', () => {
    const foo = renderer.create(<Foo />);

    expect(foo.toJSON()).toMatchSnapshot();
});

What is the expected behavior?

The ref should be usable.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

  • react@15.3.1
  • react-dom@15.3.1
  • react-test-renderer@15.3.1

Only tested with these versions.

@gaearon
Copy link
Collaborator

gaearon commented Sep 15, 2016

Thanks for taking the time to file an issue!

This is not a bug. react-test-renderer doesn’t actually use the browser (or jsdom), so there are no real <div>s we could give you.

If your components crash expecting some methods (like focus()), a workaround was implemented in #7649 and will be part of 15.4.0. It will work like this:

import React from 'react';
import renderer from 'react-test-renderer';

function createNodeMock() {
  // You can return anything from this function.
  // For example:
  return {
    focus() 
      // Do nothing
    }
  }
}

it('should have valid ref', () => {
    const foo = renderer.create(<Foo />, {createNodeMock});
    expect(foo.toJSON()).toMatchSnapshot();
});

createNodeMock also accepts element as an argument so you can check element.type and return different mocks, say, for <div> and <input>.

I hope this helps!

I will close because we generally close issues that are fixed in master, and we think this is an adequate solution.

@gaearon gaearon closed this as completed Sep 15, 2016
@armandabric
Copy link
Author

A warning could be added if we use react-test-renderer it on a component that need refs.

@gaearon
Copy link
Collaborator

gaearon commented Sep 15, 2016

Since test renderer renders deeply, I’m worried this might end up as a non-actionable warning soup. I think fixing it on a case by case basis with mocks might work out better.

@armandabric
Copy link
Author

For now I've disable the generation of the component by doing: jest.mock('./Foo');. I will give another try with react 15.4.0. Thanks for your quick reply.

@mgadda
Copy link

mgadda commented Oct 10, 2016

@gaearon Can you recommend a workaround prior to the release of React 15.4? In my case, for instance, the component which uses ref is the one being tested, so mocking the entire component (via jest.mock) is not meaningful approach.

@gaearon
Copy link
Collaborator

gaearon commented Oct 10, 2016

There is no workaround prior to its release because the workaround is added in that release. 😉
Can you try react@15.4.0-rc.2 with react-test-renderer@15.4.0-rc.2?

@mgadda
Copy link

mgadda commented Oct 10, 2016

Fair enough. I'll checkout the release candidate to make sure everything is working and then sit tight until 15.4 is released.

It also occurs to me that I could refactor the component such that imperative interactions associated with refs can be pulled out into a separate component which can then be mocked.

@piecyk
Copy link

piecyk commented Oct 25, 2016

Hi, at start just want to say great work with createNodeMockto @aweary 👏

When testing some components i stumbled on some fishy behavior, basic everything works when on first render we have components rendered that has refs callbacks, but when on update we add new components with ref callbacks we got an error
TypeError: optionscreateNodeMock is not a function

dummy example

const B = React.createClass({
  onRefEl(ref) {
    console.log('ref el', ref);
  },
  _renderEl(i) {
    return (
      <span key={i} ref={this.onRefEl}>index: {i}</span>
    );
  },
  onRef(ref) {
    console.log('ref in B', ref);
  },
  render() {
    return (
      <div ref={this.onRef}>{this.props.array.map(this._renderEl)}</div>
    );
  }
});

const A = React.createClass({
  render() {
    return <div><B array={this.props.array}/></div>;
  }
});

function createNodeMock(element) {
  console.log('yee createNodeMock called');
  return '[ref object]';
}

it('dummy test', () => {
  const component = renderer.create(<A array={[0]}/>, {createNodeMock});
  let tree = component.toJSON();
  console.log('render 0', tree);

  component.update(<A array={[0, 1]}/>);
  console.log('render 1', tree);
  // TypeError: options.createNodeMock is not a function

  tree = component.toJSON();
  expect(tree).toMatchSnapshot();
});

imho it's not correct behavior, after some digging i would say
https://github.com/facebook/react/blob/master/src/renderers/testing/ReactTestMount.js#L99-L121

change update to allow pass options maybe something like this:

ReactTestInstance.prototype.update = function (nextElement, options) {
  console.log("::my:update");
  invariant(this._component, "ReactTestRenderer: .update() can't be called after unmount.");
  var nextWrappedElement = React.createElement(TopLevelWrapper, { child: nextElement });
  var component = this._component;
  ReactUpdates.batchedUpdates(function () {
    var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(_assign({}, defaultTestOptions, options));
    transaction.perform(function () {
      ReactReconciler.receiveComponent(component, nextWrappedElement, transaction, emptyObject);
    });
    ReactUpdates.ReactReconcileTransaction.release(transaction);
  });
};

then in our test we can pass options, and we don't have TypeError 👍

it('dummy test', () => {
  const component = renderer.create(<A array={[0]}/>, {createNodeMock});
  let tree = component.toJSON();
  console.log('render 0', tree);

  component.update(<A array={[0, 1]}/>, {createNodeMock});
  console.log('render 1', tree);
  // no TypeError! 

  tree = component.toJSON();
  expect(tree).toMatchSnapshot();
});

but it's get more complicated if we want to simulate async update by setState, then also we are missing options so our dummy will look like:

// B component is the same as above...
const A = React.createClass({
  getInitialState() {
    return {
      array: []
    };
  },
  componentDidMount() {
    setTimeout(() => {
      try {
        this.setState({array: [0]});
      } catch (error) {
        // TypeError: options.createNodeMock is not a function
        console.log(error);
      }
    }, 300);
  },
  render() {
    console.log('render A');
    return <div><B array={this.state.array}/></div>;
  }
});
// createNodeMock is the same 
it('dummy test', (done) => {
  const component = renderer.create(<A/>, {createNodeMock});
  let tree = component.toJSON();
  console.log('render 0', tree);

  setTimeout(() => {
    console.log('render 1', tree);
    tree = component.toJSON();
    expect(tree).toMatchSnapshot();
    done();
  }, 600);
});

and the hard part basic from my understating ReactUpdatesFlushTransaction.getPooled(true) sets the ReactTestReconcileTransaction.testOptions to true

How the testOptions is stored... (hard to see that in quick dig in this code 💃 maybe ReactUpdatesFlushTransactionis goo place to start?

Is this making sense at all ? or what do you think guys?

One more time awesome work with this 👏 @aweary @gaearon

@gaearon
Copy link
Collaborator

gaearon commented Oct 25, 2016

Let's reopen so we don't lose track of this.

@aweary
Copy link
Contributor

aweary commented Oct 25, 2016

@piecyk thanks for the details report, I'll look into this today and see what can be done 👍

@gre
Copy link
Contributor

gre commented Nov 4, 2016

I was using the RC release for this great createNodeMock feature, but also falled into this options.createNodeMock is not a function error. which only seem to happen in some cases?

@gre
Copy link
Contributor

gre commented Nov 4, 2016

simple example that breaks (i think it's even a different bug). tested on react@15.4.0-rc.4

test("works", () => {
  class Foo extends React.Component {
    render () {
      return <div />;
    }
  }
  const inst = renderer.create(<Foo/>, { createNodeMock: () => "whatever" });
  inst.unmount();
});

test("doesnt", () => {
  class Foo extends React.Component {
    render () {
      return <div ref="foo" />;
    }
  }
  const inst = renderer.create(<Foo/>, { createNodeMock: () => "whatever" });
  inst.unmount();
});

will produce

  ● doesnt

    TypeError: Cannot read property 'getTestOptions' of undefined

      at ReactTestComponent.getPublicInstance (node_modules/react-test-renderer/lib/ReactTestRenderer.js:69:30)
      at Object.removeComponentAsRefFrom (node_modules/react-test-renderer/lib/ReactOwner.js:86:76)
      at detachRef (node_modules/react-test-renderer/lib/ReactRef.js:32:16)
      at Object.<anonymous>.ReactRef.detachRefs (node_modules/react-test-renderer/lib/ReactRef.js:84:5)
      at Object.unmountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:78:14)
      at ReactCompositeComponentWrapper.unmountComponent (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:418:23)
      at Object.unmountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:79:22)
      at ReactCompositeComponentWrapper.unmountComponent (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:418:23)
      at Object.unmountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:79:22)
      at node_modules/react-test-renderer/lib/ReactTestMount.js:97:23
      at ReactTestReconcileTransaction.perform (node_modules/react-test-renderer/lib/Transaction.js:140:20)
      at node_modules/react-test-renderer/lib/ReactTestMount.js:96:17
      at ReactDefaultBatchingStrategyTransaction.perform (node_modules/react-test-renderer/lib/Transaction.js:140:20)
      at Object.batchedUpdates (node_modules/react-test-renderer/lib/ReactDefaultBatchingStrategy.js:62:26)
      at Object.batchedUpdates (node_modules/react-test-renderer/lib/ReactUpdates.js:97:27)
      at ReactTestInstance.Object.<anonymous>.ReactTestInstance.unmount (node_modules/react-test-renderer/lib/ReactTestMount.js:94:16)
      at Object.<anonymous>._react2.default.Component (src/GL/gl-react-headless/tests/all.test.js:53:8)
      at process._tickCallback (internal/process/next_tick.js:103:7)

  ✓ works (8ms)
  ✕ doesnt (4ms)

what's weird is I have refs working in some cases (like most of my usecases) but there are specific cases that definitely break. Let me know if you want me to do more investigation.

@gre
Copy link
Contributor

gre commented Nov 9, 2016

do you guys plan to fix this for 15.4.0 ? This bug makes createNodeMock very unreliable when you write more advanced tests..

@aweary
Copy link
Contributor

aweary commented Nov 9, 2016

I unfortunately haven't had a lot of time to work on React lately, I can try to make an effort tonight after work to fix it.

@piecyk
Copy link

piecyk commented Nov 10, 2016

I will try to have another look on that...
if some is starting with it, most simple test that we want to resolve is below
( add it at end of suit ReactTestRenderer )

  it('dynamic ref', () => {
    const onRef = jest.fn();

    class A extends React.Component {
      state = {a: []}; // but when on init we set state = {a: [1]}; it will pass
      componentDidMount() {
        this.setState({a: [1]});
      }
      renderChild(i) {
        return <div key={i} ref={onRef}>{i}</div>
      }
      render() {
        return <div>{this.state.a.map(this.renderChild)}</div>
      }
    }

    function createNodeMock(element) {
      return null;
    }

    ReactTestRenderer.create(<A/>, {createNodeMock});
    expect(onRef).toBeCalled();
  })

@gaearon
Copy link
Collaborator

gaearon commented Nov 11, 2016

Thanks a lot for providing repro cases and to @aweary for fixing this in #8261.

@gre
Copy link
Contributor

gre commented Nov 16, 2016

It works great! thanks you guys for fixing this.

WebsByTodd added a commit to mytakedotorg/mtdo that referenced this issue Sep 5, 2017
See facebook/react#7740 for details.

1) resetHeight() is called and tries to set this.div.innerHTML. Shallow renderer does not use a DOM so doesn't know what this.div is.

2) this.textarea.focus() is called. Mock out focus.
DominikGuzei added a commit to input-output-hk/react-polymorph that referenced this issue Feb 5, 2020
While debugging a testing issue with the new scrollbar component i stumbled over the known problem of „react-test-renderer“ not being able to handle element refs correctly (since it doesn’t involve any real DOM rendering).

You can read more about that issue here: facebook/react#7740

This was the root cause and i couldnt make it work with react-test-renderer, so i refactored all the snapshot tests to use enzyme (which supports full DOM rendering). You can see the difference (react-test-renderer outputs a JSON with react component „markup“ whereas enzyme outputs only plain DOM nodes)
DominikGuzei added a commit to input-output-hk/react-polymorph that referenced this issue Apr 22, 2020
* [DDW-829] Installs react-custom-scrollbars as dependency

* [DDW-829] Creates ScrollBar component

* [DDW-829] Creates SCROLLBAR identifier

* [DDW-829] Creates ScrollBarSkin using react-custom-scrollbars package

* [DDW-829] Exports ScrollBarSkin from index using identifier

* [DDW-829] Changes render prop to children

* [DDW-829] Adds SCROLLBAR_THEME_API

* [DDW-829] Adds theme api export

* [DDW-829] Creates SimpleScrollBar theme file

* [DDW-829] Exports SimpleScrollBar theme file

* [DDW-829] Adds configurable CSS vars to theme file

* [DDW-829] Swaps className prop for style prop

* [DDW-829] Adds ScrollBar story

* [DDW-829] Fixes ScrollBar height issue

* [DDW-829] Cleans up ScrollBar storybook styles

* [DDW-829] Updates CHANGELOG

* [DDW-829] Removes root class from ScrollBar's theme

* [DDW-829] Adds optionHeight prop to Options component

* [DDW-829] Adds optionHeight prop to OptionsSkin and fixes scroll bar height calculation

* Add support for *.module.scss file name convention

* [DDW-829] Adds big countries list for testing

* [DDW-829] Use maintained custom scrollbars package

* [DDW-829] Fixes ESLint warning in ScrollBar story

* [DDW-829] Arranges ScrollBar scss vars in ABC order

* [DDW-829] Makes ScrollBar thumb darker

* [DDW-829] Fixes ESLint error in Autocomplete behavior tests

* [DDW-829] Fix broken jest snapshots by using enzyme

While debugging a testing issue with the new scrollbar component i stumbled over the known problem of „react-test-renderer“ not being able to handle element refs correctly (since it doesn’t involve any real DOM rendering).

You can read more about that issue here: facebook/react#7740

This was the root cause and i couldnt make it work with react-test-renderer, so i refactored all the snapshot tests to use enzyme (which supports full DOM rendering). You can see the difference (react-test-renderer outputs a JSON with react component „markup“ whereas enzyme outputs only plain DOM nodes)

* [DDW-829] Updates CHANGELOG to include snapshot test refactoring

* Prepares CHANGELOG for 0.9.2 release

* 0.9.2

* 0.9.2-rc.1

* Fixes prepare-sass-files-for-publishing.js

* 0.9.2-rc.2

* [DDW-733] Implement password input component

* [DDW-733] Fixes ESLint warning

* [DDW-733] Fixes flow error

* [DDW-733] Fixes CSS variable names and adds comments to theme file

* [DDW-733] Updates CHANGELOG

* [DDW-1227] Fix options component dimensions (#135)

* [DDW-1227] Introduce a fix for options fixed height

* [DDW-1227] Add more optionHeight declarations

* [DDW-1227] Fix typo

* [DDW-1227] Add GlobalListeners mouse event on root element position

* [DDW-1227] Fix flow issues

* [DDW-1227] Update CHANGELOG

* [DDW-1227] Update stoybook stories due to latest changes

* [DDW-1227] CHANGELOG update

* Prepare release 0.9.3 (#136)

* Prepare release 0.9.3

Co-authored-by: MarcusHurney <marcushurney@gmail.com>
Co-authored-by: Danilo Prates <daniloprates@gmail.com>
Co-authored-by: Tomislav Horaček <tomislav.horacek@thespian.hr>
nikolaglumac added a commit to input-output-hk/react-polymorph that referenced this issue Jun 25, 2020
* [DDW-829] Installs react-custom-scrollbars as dependency

* [DDW-829] Creates ScrollBar component

* [DDW-829] Creates SCROLLBAR identifier

* [DDW-829] Creates ScrollBarSkin using react-custom-scrollbars package

* [DDW-829] Exports ScrollBarSkin from index using identifier

* [DDW-829] Changes render prop to children

* [DDW-829] Adds SCROLLBAR_THEME_API

* [DDW-829] Adds theme api export

* [DDW-829] Creates SimpleScrollBar theme file

* [DDW-829] Exports SimpleScrollBar theme file

* [DDW-829] Adds configurable CSS vars to theme file

* [DDW-829] Swaps className prop for style prop

* [DDW-829] Adds ScrollBar story

* [DDW-829] Fixes ScrollBar height issue

* [DDW-829] Cleans up ScrollBar storybook styles

* [DDW-829] Updates CHANGELOG

* [DDW-829] Removes root class from ScrollBar's theme

* [DDW-829] Adds optionHeight prop to Options component

* [DDW-829] Adds optionHeight prop to OptionsSkin and fixes scroll bar height calculation

* Add support for *.module.scss file name convention

* [DDW-829] Adds big countries list for testing

* [DDW-829] Use maintained custom scrollbars package

* [DDW-829] Fixes ESLint warning in ScrollBar story

* [DDW-829] Arranges ScrollBar scss vars in ABC order

* [DDW-829] Makes ScrollBar thumb darker

* [DDW-829] Fixes ESLint error in Autocomplete behavior tests

* [DDW-829] Fix broken jest snapshots by using enzyme

While debugging a testing issue with the new scrollbar component i stumbled over the known problem of „react-test-renderer“ not being able to handle element refs correctly (since it doesn’t involve any real DOM rendering).

You can read more about that issue here: facebook/react#7740

This was the root cause and i couldnt make it work with react-test-renderer, so i refactored all the snapshot tests to use enzyme (which supports full DOM rendering). You can see the difference (react-test-renderer outputs a JSON with react component „markup“ whereas enzyme outputs only plain DOM nodes)

* [DDW-829] Updates CHANGELOG to include snapshot test refactoring

* Prepares CHANGELOG for 0.9.2 release

* 0.9.2

* 0.9.2-rc.1

* Fixes prepare-sass-files-for-publishing.js

* 0.9.2-rc.2

* [DDW-733] Implement password input component

* [DDW-733] Fixes ESLint warning

* [DDW-733] Fixes flow error

* [DDW-733] Fixes CSS variable names and adds comments to theme file

* [DDW-733] Updates CHANGELOG

* [DDW-1227] Fix options component dimensions (#135)

* [DDW-1227] Introduce a fix for options fixed height

* [DDW-1227] Add more optionHeight declarations

* [DDW-1227] Fix typo

* [DDW-1227] Add GlobalListeners mouse event on root element position

* [DDW-1227] Fix flow issues

* [DDW-1227] Update CHANGELOG

* [DDW-1227] Update stoybook stories due to latest changes

* [DDW-1227] CHANGELOG update

* Prepare release 0.9.3 (#136)

* Prepare release 0.9.3

* [DDW-246]: Eliminate usage of deprecated lifecycle methods (#138)

* [DDW-246]: Eliminate usage of deprecated lifecycle methods
* [DDW-246]: Restore single quote usage
* [DDW-246]: Fix props type in tooltip component

* [DDW-733] Refactor jest setup (#139)

Co-authored-by: Nikola Glumac <niglumac@gmail.com>

* [DDW-170] Improved Password input (#140)

* [DDW-733] Refactor jest setup

* [DDW-733] Implement advanced password input

* [DDW-733] Refactor jest setup

* [DDW-733] Implement advanced password input

* [DDW-733] Center password input asteriks vertically

* [DDW-733] Refine indicator and tooltip styles

* [DDW-733] Add theme var for tooltip font-family

* [DDW-733] Fix tooltip default font-family

Co-authored-by: Nikola Glumac <niglumac@gmail.com>

* [DDW-170] Improve password repeat feature

* [DDW-170] Update changelog

* [DDW-170] Prepare changelog for vNext

* 0.9.4-rc.1

* [DDW-170] Add className prop to password input

* 0.9.4-rc.2

* [DDW-170] Fix tooltip regression on hover

* 0.9.4-rc.3

* [DDW-170] Fixes show on focus feature

* 0.9.4-rc.4

* [DDW-170] Make tooltip border-radius configurable

* 0.9.4-rc.5

* [DDW-170] Remove margin from password input

* [DDW-170] Fix custom error logic

* 0.9.4-rc.6

* [DDW-170] Fix pw input bg colors

* 0.9.4-rc.7

* [DDW-170] Add dedicated flag for password repeats

* 0.9.4-rc.8

* [DDW-170] Improve password repeat feature (#141)

* [DDW-170] Improve password repeat feature

* [DDW-170] Update changelog

* [DDW-170] Prepare changelog for vNext

* 0.9.4-rc.1

* [DDW-170] Add className prop to password input

* 0.9.4-rc.2

* [DDW-170] Fix tooltip regression on hover

* 0.9.4-rc.3

* [DDW-170] Fixes show on focus feature

* 0.9.4-rc.4

* [DDW-170] Make tooltip border-radius configurable

* 0.9.4-rc.5

* [DDW-170] Remove margin from password input

* [DDW-170] Fix custom error logic

* 0.9.4-rc.6

* [DDW-170] Fix pw input bg colors

* 0.9.4-rc.7

* 0.9.4

* Update changelog

Co-authored-by: MarcusHurney <marcushurney@gmail.com>
Co-authored-by: Danilo Prates <daniloprates@gmail.com>
Co-authored-by: Tomislav Horaček <tomislav.horacek@thespian.hr>
Co-authored-by: Yakov Karavelov <yakovkaravelov@users.noreply.github.com>
Co-authored-by: Nikola Glumac <niglumac@gmail.com>
DominikGuzei added a commit to input-output-hk/react-polymorph that referenced this issue Sep 21, 2020
* [DDW-829] Installs react-custom-scrollbars as dependency

* [DDW-829] Creates ScrollBar component

* [DDW-829] Creates SCROLLBAR identifier

* [DDW-829] Creates ScrollBarSkin using react-custom-scrollbars package

* [DDW-829] Exports ScrollBarSkin from index using identifier

* [DDW-829] Changes render prop to children

* [DDW-829] Adds SCROLLBAR_THEME_API

* [DDW-829] Adds theme api export

* [DDW-829] Creates SimpleScrollBar theme file

* [DDW-829] Exports SimpleScrollBar theme file

* [DDW-829] Adds configurable CSS vars to theme file

* [DDW-829] Swaps className prop for style prop

* [DDW-829] Adds ScrollBar story

* [DDW-829] Fixes ScrollBar height issue

* [DDW-829] Cleans up ScrollBar storybook styles

* [DDW-829] Updates CHANGELOG

* [DDW-829] Removes root class from ScrollBar's theme

* [DDW-829] Adds optionHeight prop to Options component

* [DDW-829] Adds optionHeight prop to OptionsSkin and fixes scroll bar height calculation

* Add support for *.module.scss file name convention

* [DDW-829] Adds big countries list for testing

* [DDW-829] Use maintained custom scrollbars package

* [DDW-829] Fixes ESLint warning in ScrollBar story

* [DDW-829] Arranges ScrollBar scss vars in ABC order

* [DDW-829] Makes ScrollBar thumb darker

* [DDW-829] Fixes ESLint error in Autocomplete behavior tests

* [DDW-829] Fix broken jest snapshots by using enzyme

While debugging a testing issue with the new scrollbar component i stumbled over the known problem of „react-test-renderer“ not being able to handle element refs correctly (since it doesn’t involve any real DOM rendering).

You can read more about that issue here: facebook/react#7740

This was the root cause and i couldnt make it work with react-test-renderer, so i refactored all the snapshot tests to use enzyme (which supports full DOM rendering). You can see the difference (react-test-renderer outputs a JSON with react component „markup“ whereas enzyme outputs only plain DOM nodes)

* [DDW-829] Updates CHANGELOG to include snapshot test refactoring

* Prepares CHANGELOG for 0.9.2 release

* 0.9.2

* 0.9.2-rc.1

* Fixes prepare-sass-files-for-publishing.js

* 0.9.2-rc.2

* [DDW-733] Implement password input component

* [DDW-733] Fixes ESLint warning

* [DDW-733] Fixes flow error

* [DDW-733] Fixes CSS variable names and adds comments to theme file

* [DDW-733] Updates CHANGELOG

* [DDW-1227] Fix options component dimensions (#135)

* [DDW-1227] Introduce a fix for options fixed height

* [DDW-1227] Add more optionHeight declarations

* [DDW-1227] Fix typo

* [DDW-1227] Add GlobalListeners mouse event on root element position

* [DDW-1227] Fix flow issues

* [DDW-1227] Update CHANGELOG

* [DDW-1227] Update stoybook stories due to latest changes

* [DDW-1227] CHANGELOG update

* Prepare release 0.9.3 (#136)

* Prepare release 0.9.3

* [DDW-246]: Eliminate usage of deprecated lifecycle methods (#138)

* [DDW-246]: Eliminate usage of deprecated lifecycle methods
* [DDW-246]: Restore single quote usage
* [DDW-246]: Fix props type in tooltip component

* [DDW-733] Refactor jest setup (#139)

Co-authored-by: Nikola Glumac <niglumac@gmail.com>

* [DDW-170] Improved Password input (#140)

* [DDW-733] Refactor jest setup

* [DDW-733] Implement advanced password input

* [DDW-733] Refactor jest setup

* [DDW-733] Implement advanced password input

* [DDW-733] Center password input asteriks vertically

* [DDW-733] Refine indicator and tooltip styles

* [DDW-733] Add theme var for tooltip font-family

* [DDW-733] Fix tooltip default font-family

Co-authored-by: Nikola Glumac <niglumac@gmail.com>

* [DDW-170] Improve password repeat feature

* [DDW-170] Update changelog

* [DDW-170] Prepare changelog for vNext

* 0.9.4-rc.1

* [DDW-170] Add className prop to password input

* 0.9.4-rc.2

* [DDW-170] Fix tooltip regression on hover

* 0.9.4-rc.3

* [DDW-170] Fixes show on focus feature

* 0.9.4-rc.4

* [DDW-170] Make tooltip border-radius configurable

* 0.9.4-rc.5

* [DDW-170] Remove margin from password input

* [DDW-170] Fix custom error logic

* 0.9.4-rc.6

* [DDW-170] Fix pw input bg colors

* 0.9.4-rc.7

* [DDW-170] Add dedicated flag for password repeats

* 0.9.4-rc.8

* [DDW-170] Improve password repeat feature (#141)

* [DDW-170] Improve password repeat feature

* [DDW-170] Update changelog

* [DDW-170] Prepare changelog for vNext

* 0.9.4-rc.1

* [DDW-170] Add className prop to password input

* 0.9.4-rc.2

* [DDW-170] Fix tooltip regression on hover

* 0.9.4-rc.3

* [DDW-170] Fixes show on focus feature

* 0.9.4-rc.4

* [DDW-170] Make tooltip border-radius configurable

* 0.9.4-rc.5

* [DDW-170] Remove margin from password input

* [DDW-170] Fix custom error logic

* 0.9.4-rc.6

* [DDW-170] Fix pw input bg colors

* 0.9.4-rc.7

* Bump lodash from 4.17.15 to 4.17.19

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>

* Bump elliptic from 6.4.0 to 6.5.3 (#144)

Bumps [elliptic](https://github.com/indutny/elliptic) from 6.4.0 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](indutny/elliptic@v6.4.0...v6.5.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [issue-145] Remove deprecated postinstall-build package (#146)

* [issue-145] Remove deprecated postinstall-build package

* [issue-145] Update changelog

* 0.9.5-rc.1

* Bump lodash.merge from 4.6.1 to 4.6.2 (#148)

Bumps [lodash.merge](https://github.com/lodash/lodash) from 4.6.1 to 4.6.2.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump node-sass from 4.13.0 to 4.13.1 (#147)

Bumps [node-sass](https://github.com/sass/node-sass) from 4.13.0 to 4.13.1.
- [Release notes](https://github.com/sass/node-sass/releases)
- [Changelog](https://github.com/sass/node-sass/blob/master/CHANGELOG.md)
- [Commits](sass/node-sass@v4.13.0...v4.13.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominik Guzei <dominik.guzei@gmail.com>

* 0.9.5

Co-authored-by: MarcusHurney <marcushurney@gmail.com>
Co-authored-by: Danilo Prates <daniloprates@gmail.com>
Co-authored-by: Tomislav Horaček <tomislav.horacek@thespian.hr>
Co-authored-by: Yakov Karavelov <yakovkaravelov@users.noreply.github.com>
Co-authored-by: Nikola Glumac <niglumac@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@BobrImperator
Copy link

Just stumbled upon this, my solution for this was to not use react-test-renderer, but render from @testing-library/react

it("renders", () => {
  const { asFragment } = render(<Header text="Hello!" />);
  expect(asFragment()).toMatchSnapshot();
});

Shoutout to https://www.leighhalliday.com/introduction-react-testing-library where I was able to find this API for generating snapshots.

@allestaire
Copy link

Just stumbled upon this, my solution for this was to not use react-test-renderer, but render from @testing-library/react

it("renders", () => {
  const { asFragment } = render(<Header text="Hello!" />);
  expect(asFragment()).toMatchSnapshot();
});

Shoutout to https://www.leighhalliday.com/introduction-react-testing-library where I was able to find this API for generating snapshots.

Tried this but still useRef is always null

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

No branches or pull requests

8 participants