Skip to content

Instantly share code, notes, and snippets.

@elvisgiv
Created July 3, 2019 12:34
Show Gist options
  • Save elvisgiv/089f16bd4d6b3e6fcb04f1ff9a9f5901 to your computer and use it in GitHub Desktop.
Save elvisgiv/089f16bd4d6b3e6fcb04f1ff9a9f5901 to your computer and use it in GitHub Desktop.

Error: The target '' could not be identified in the dom, tip: check spelling

in my case it was Popover from _reactstrap

in blabla.spec.js

import React from 'react';
import {shallow, mount} from 'enzyme';
import {expect} from 'chai';
import blabla from '../src/components/page_components/blabla';
import {Router} from "react-router";
import {createBrowserHistory} from "history";
const history = createBrowserHistory();

// for add POPOVER to JSDOM
const Popover = document.createElement('Popover');
document.body.appendChild(Popover);
let props = {};
const wrapper = mount(
    <Router history={history}>
        <SchainContent {...props}/>
    </Router>, {attachTo: Popover}
);

const componentInstance = wrapper
    .childAt(0) // could also be .find(Foo)
    .instance();

describe('<blabla/>', function () {
    it('should have an "something"', function () {
        componentInstance.setState({loaded: true});
        wrapper.update();
        console.log('debug', wrapper.debug())
    });
});    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment