Can anyone tell me why this tests fails? I meant, it passes when it should fail.
const { describe, it } = global;
import { Factory } from 'meteor/dburles:factory';
import React from 'react';
import { shallow } from 'enzyme';
import chai, {expect} from 'chai';
import matcher from 'chai-react-element';
chai.use(matcher);
// import { chai } from 'meteor/practicalmeteor:chai';
class SimpleTest extends React.PureComponent {
render() {
return (
<div>
goodbye
</div>
);
}
}
describe('SimpleTest', () => {
it('should render', () => {
// const todo = Factory.build('todo', { text: 'testing', checked: false });
const simpleTest = shallow(<SimpleTest />);
expect(simpleTest).to.have.text('hello world');
});
});
Cool, seems fairly simple the way you are doing your test.
Could you post the correction to your code that works?
And also how you referenced const { describe, it } = global;
Any more details would be awesome! Thanks!
Correction
const { describe, it } = global;
import { Factory } from 'meteor/dburles:factory';
import React from 'react';
import { shallow } from 'enzyme';
import chai, {expect} from 'chai';
**import chaiEnzyme from 'chai-enzyme'**
**chai.use(chaiEnzyme());**
// import { chai } from 'meteor/practicalmeteor:chai';
class SimpleTest extends React.PureComponent {
render() {
return (
<div>
goodbye
</div>
);
}
}
describe('SimpleTest', () => {
it('should render', () => {
// const todo = Factory.build('todo', { text: 'testing', checked: false });
const simpleTest = shallow(<SimpleTest />);
expect(simpleTest).to.have.text('hello world');
});
});
I am defining:
const { describe, it } = global;
In case I want to run the test using mocha
from npm.
2 Likes