Skip to main content
Commonmark migration
Source Link

Result: failed

 

Expected result should be: passed

Result: failed

 

Expected result should be: passed

Result: failed

Expected result should be: passed

added 829 characters in body; edited title
Source Link
Martin
  • 83
  • 1
  • 5

Error in Testing nested components with Jest js tests: TypeError: parentInstance.children.indexOf is not a functionand snapshot returns null

Edited on 04.03.2020:

Now I changed my code so it tests from the main component from App.js which works great, but I want to test just the child component SelectColumn. I tried with shallow and find but the snapshot is always exports[...] = null;

import React from "react";
import SelectColumn from "../App.js";
import { test_snapshot_of } from "./utils.js";
import Enzyme, { shallow } from "enzyme";
import Adapter from "enzyme-adapter-react-16";

Enzyme.configure({ adapter: new Adapter() });

// mock uniqid to have consistent names
// https://stackoverflow.com/a/44538270/396730
jest.mock("uniqid", () => i => i + "uniqid");

const wrapper = shallow(<SelectColumn />);
const rootElement = wrapper.find("#root");
test_snapshot_of("Render SelectColumn", overview => rootElement);

Error in Jest js tests: TypeError: parentInstance.children.indexOf is not a function

Testing nested components with Jest and snapshot returns null

Edited on 04.03.2020:

Now I changed my code so it tests from the main component from App.js which works great, but I want to test just the child component SelectColumn. I tried with shallow and find but the snapshot is always exports[...] = null;

import React from "react";
import SelectColumn from "../App.js";
import { test_snapshot_of } from "./utils.js";
import Enzyme, { shallow } from "enzyme";
import Adapter from "enzyme-adapter-react-16";

Enzyme.configure({ adapter: new Adapter() });

// mock uniqid to have consistent names
// https://stackoverflow.com/a/44538270/396730
jest.mock("uniqid", () => i => i + "uniqid");

const wrapper = shallow(<SelectColumn />);
const rootElement = wrapper.find("#root");
test_snapshot_of("Render SelectColumn", overview => rootElement);
added 578 characters in body; edited title
Source Link
Martin
  • 83
  • 1
  • 5

Error in Jest js tests: react-modalTypeError: No elements were found for selector #rootparentInstance.children.indexOf is not a function

I am trying to create SelectColumn.test.js similar to Summary.test.js

https://gitlab.com/sosy-lab/software/benchexec/-/blob/SelectColumn.test/benchexec/tablegenerator/react-table/src/tests/SelectColumn.test.js

But unfortunately not successful, I tried all solutions from code forums. But seems I am doing something wrong.

Result: failed

Expected result should be: passed

Error:

react-modal: No elements were found for selector #root.

      180 | 
      181 |   render() {
    > 182 |     ReactModal.setAppElement("#root");
          |                ^
      183 |     return (
      184 |       <ReactModal
      185 |         className="overlay"

Edited on 01.03.2020:

I added <div id="root"> which fixed error:

react-modal: No elements were found for selector #root.

but now new error is showing:

TypeError: parentInstance.children.indexOf is not a function

in code:

      81 |           .create(<Overview data={data} />)
      82 |           .getInstance();
    > 83 |         const component = renderer.create(component_func(overview));
         |                                    ^
      84 | 
      85 |         expect(component).toMatchSnapshot();
      86 |       });

I tried to move ReactModal.setAppElement to componentDidMount but it seems not to be the solution.

Error in Jest js tests: react-modal: No elements were found for selector #root

I am trying to create SelectColumn.test.js similar to Summary.test.js

https://gitlab.com/sosy-lab/software/benchexec/-/blob/SelectColumn.test/benchexec/tablegenerator/react-table/src/tests/SelectColumn.test.js

But unfortunately not successful, I tried all solutions from code forums. But seems I am doing something wrong.

Result: failed

Expected result should be: passed

Error:

react-modal: No elements were found for selector #root.

      180 | 
      181 |   render() {
    > 182 |     ReactModal.setAppElement("#root");
          |                ^
      183 |     return (
      184 |       <ReactModal
      185 |         className="overlay"

Error in Jest js tests: TypeError: parentInstance.children.indexOf is not a function

I am trying to create SelectColumn.test.js similar to Summary.test.js

https://gitlab.com/sosy-lab/software/benchexec/-/blob/SelectColumn.test/benchexec/tablegenerator/react-table/src/tests/SelectColumn.test.js

But unfortunately not successful, I tried all solutions from code forums. But seems I am doing something wrong.

Result: failed

Expected result should be: passed

Error:

react-modal: No elements were found for selector #root.

      180 | 
      181 |   render() {
    > 182 |     ReactModal.setAppElement("#root");
          |                ^
      183 |     return (
      184 |       <ReactModal
      185 |         className="overlay"

Edited on 01.03.2020:

I added <div id="root"> which fixed error:

react-modal: No elements were found for selector #root.

but now new error is showing:

TypeError: parentInstance.children.indexOf is not a function

in code:

      81 |           .create(<Overview data={data} />)
      82 |           .getInstance();
    > 83 |         const component = renderer.create(component_func(overview));
         |                                    ^
      84 | 
      85 |         expect(component).toMatchSnapshot();
      86 |       });

I tried to move ReactModal.setAppElement to componentDidMount but it seems not to be the solution.

edited tags; edited title
Link
Martin
  • 83
  • 1
  • 5
Loading
Source Link
Martin
  • 83
  • 1
  • 5
Loading