You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**
* Components using the react-intl module require access to the intl context.
* This is not available when mounting single components in Enzyme.
* These helper functions aim to address that and wrap a valid,
* English-locale intl context around them.
*/
import React from 'react';
import { IntlProvider, intlShape } from 'react-intl';
import { mount, shallow } from 'enzyme';
// You can pass your messages to the IntlProvider. Optional: remove if unneeded.
const messages = require('../assets/en.json'); // en.json
// Create the IntlProvider to retrieve context for wrapping around.
const intlProvider = new IntlProvider({ locale: 'en', messages }, {});
const { intl } = intlProvider.getChildContext();
/**
* When using React-Intl `injectIntl` on components, props.intl is required.
*/
function nodeWithIntlProp(node) {
return React.cloneElement(node, { intl });
}
export function shallowWithIntl(node) {
return shallow(
nodeWithIntlProp(node),
{
context: {intl}
}
);
}
export function mountWithIntl(node, { context, childContextTypes } = {}) {
return mount(
nodeWithIntlProp(node),
{
context: Object.assign({}, context, {intl}),
childContextTypes: Object.assign({}, { intl: intlShape }, childContextTypes)
}
);
}
LoginForm
✖ Should render
PhantomJS 2.1.1 (Mac OS X 0.0.0)
Method “props” is only meant to be run on a single node. 0 found instead.
[email protected]:54278:149
[email protected]:53668:28
tests.webpack.js:8250:58
I have this helper class defined:
and this is my test
I have tried installing karma-intl-shim:
karma.config.js
But when running my test, I get this error:
Any idea to what may be wrong? I've tried following the https://github.com/yahoo/react-intl/wiki/Testing-with-React-Intl but no success.
Any help would be greatly appreciated. Thanks!
Frank
The text was updated successfully, but these errors were encountered: