-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
blank()
does not return errors for non-null components as suggested
#126
Labels
Comments
Confirmed this is indeed a bug when the component is mounted (not when using class NullFixture extends React.Component {
render () {
return (<p>hi</p>)
}
}
const it = createTest(<NullFixture />)
describe('#blank', () => {
describe('()', () => {
it('passes negated when the actual does not match the expected', (wrapper) => {
expect(wrapper).to.not.be.blank()
})
})
}) Results:
|
The problem still exists, now in class NullFixture extends React.Component {
render () {
return (<AnotherNullFixture/>)
}
}
class AnotherNullFixture extends React.Component {
render () {
return (<p>text</p>)
}
}
it = createTest(<NullFixture />)
describe.only('#blank', () => {
describe('(non-empty component)', () => {
it('passes when the actual matches the expected', (wrapper) => {
expect(wrapper).to.not.be.blank()
})
// it('fails when the actual does not match the expected', (wrapper) => {
// expect(() => {
// expect(wrapper).to.be.blank()
// }).to.throw()
// })
})
}) Results: NODE_ENV=test npx mocha test/blank.test.js
#blank
(non-empty component)
1) (shallow): passes when the actual matches the expected
✓ (mount): passes when the actual matches the expected
2) (render): passes when the actual matches the expected
1 passing (365ms)
2 failing
1) #blank (non-empty component) (shallow): passes when the actual matches the expected:
AssertionError: expected <NullFixture /> not to be empty
HTML:
<p>text</p>
at /Users/user/Documents/_prj/chai-enzyme/test/blank.test.js:60:33
at Context.<anonymous> (/Users/user/Documents/_prj/chai-enzyme/test/support/createTest.js:14:7)
at callFn (/Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runnable.js:348:21)
at Test.Runnable.run (/Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runnable.js:340:7)
at Runner.runTest (/Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runner.js:443:10)
at /Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runner.js:549:12
at next (/Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runner.js:361:14)
at /Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runner.js:371:7
at next (/Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runner.js:295:14)
at Immediate.<anonymous> (/Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runner.js:339:5)
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)
2) #blank (non-empty component) (render): passes when the actual matches the expected:
AssertionError: expected the node in <??? /> not to be empty
HTML:
<p>text</p>
at /Users/user/Documents/_prj/chai-enzyme/test/blank.test.js:60:33
at Context.<anonymous> (/Users/user/Documents/_prj/chai-enzyme/test/support/createTest.js:26:7)
at callFn (/Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runnable.js:348:21)
at Test.Runnable.run (/Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runnable.js:340:7)
at Runner.runTest (/Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runner.js:443:10)
at /Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runner.js:549:12
at next (/Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runner.js:361:14)
at /Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runner.js:371:7
at next (/Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runner.js:295:14)
at Immediate.<anonymous> (/Users/user/Documents/_prj/chai-enzyme/node_modules/mocha/lib/runner.js:339:5)
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5) It seems not correct to check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was struggling to get
blank()
to fail when a component had content. I eventually copied the exact code from the example but had it return content rather than null:The example tests do not fail (they pass):
The text was updated successfully, but these errors were encountered: