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

Warning: Failed context type: The context router is marked as required in Component, but its value is undefined. #4

Closed
velidan opened this issue Mar 2, 2018 · 2 comments

Comments

@velidan
Copy link

velidan commented Mar 2, 2018

Hello. I'm trying to use this package to mock the router context but it still doesn't work event after context providing.

Here is my test.

Btw I also have a question. Even when I'm using the MemoryRouter and mount feature how I can test some method of my real component. enzymeWrapper.instance() doesn't work because the root component is MemoryRouter
Thanks for any help.

import * as React from "react";
// import { MemoryRouter } from "react-router-dom";
import {shallow, ShallowWrapper} from "enzyme";
import createRouterContext from 'react-router-test-context'
import Overview from "../src/modules/customer/Overview";
import { profilesStore } from "../src/store";

let overview: ShallowWrapper<undefined, undefined>;

beforeEach(function() {
		overview=shallow(

			<Overview profilesStore={profilesStore}/>,
			{ context : createRouterContext() }
	)
});

describe('Overview component test suite', () => {
    it('should have an one section with id container', () => {
        expect(overview.find("#container")).toHaveLength(1);
    });
});

Here is the issue message
Warning: Failed context type: The context router is marked as required in
Component, but its value is undefined.
in Link
in header
in section
in default_1

@pshrmn
Copy link
Owner

pshrmn commented Mar 2, 2018

Probably related to this https://github.com/pshrmn/react-router-test-context#mount.

@velidan
Copy link
Author

velidan commented Mar 5, 2018

I don't sure that it's really answer. Unfortunately, I can't test in now. But thanks for a quick answer, I'll close the issue.

@velidan velidan closed this as completed Mar 5, 2018
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

2 participants