Cannot read property 'replace' of undefined
Closed this issue · 2 comments
danielmollmorgan commented
I'm currently getting the following error when using mount()
- Uncaught TypeError: Cannot read property 'replace' of undefined
with the latest version of chai-enzyme
.
If I revert to the previous chai-enzyme@0.4.1
there is no error and all runs ok. I haven't been able to track the cause yet.
Dependency versions:
chai-enzyme@0.4.2
enzyme@2.1.0
chai@3.5.0
mocha@2.4.5
Basic example of test that causes the in browser error:
import 'babel-polyfill';
import ArticleTemplate from '../src';
import React from 'react';
import article from '../stubbed/article';
import chai from 'chai';
import chaiEnzyme from 'chai-enzyme';
import { mount } from 'enzyme';
chai.use(chaiEnzyme()).should();
describe('ArticleTemplate', () => {
let props = null;
beforeEach(() => {
props = {
id: article.id,
slug: article.slug,
content: article.content,
};
});
it('renders a React element', () => {
React.isValidElement(<ArticleTemplate {...props} />).should.equal(true);
});
describe('Rendering', () => {
let rendered = null;
let articlePage = null;
beforeEach(() => {
rendered = mount(<ArticleTemplate {...props} />);
articlePage = rendered.find('.article-template');
});
it('renders <article />', () => {
articlePage.should.have.tagName('article');
});
});
});
ayrton commented
Thanks for reporting Daniel, I will look into this :)
danielmollmorgan commented
@ayrton apologies, I've figured out, and it just must have been a coincidence with reverting back a version but it's down to ads causing a global leak in the tests. Yeah, ads in the test :(