-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Consider a way to support/add equalJSX method #186
Comments
Note: this is assertion is doable using https://github.com/algolia/react-element-to-jsx-string |
Also please note that another method is really handy when testing react component: |
@MoOx The ability to add custom assertions is on the roadmap. |
You can already use any custom assertion. The only minus is that assertion counting doesn't work. We plan to add support for adding custom assertions. See #49. |
FYI, here is how I do for now import "babel-core/register"
import test from "ava"
import React, { Component } from "react"
import { createRenderer } from "react-addons-test-utils"
// import ReactDOMServer from "react-dom/server"
import expect from "expect"
import expectJSX from "expect-jsx"
expect.extend(expectJSX)
import MyComponent from ".."
test("MyComponent default render", (t) => {
const renderer = createRenderer()
renderer.render(
<MyComponent />
)
expect(
renderer.getRenderOutput()
)
.toEqualJSX(
<div />
)
}) Result ❯ npm run ava
> ~@ ava ~
> ava "web_modules/**/__tests__/*.js"
✖ MyComponent default render Expected '<div>\n <div className="container-navigation-list" />\n</div>' to equal '<div />'
1 test failed
1. MyComponent default render
Error: Expected '<div>\n <div className="container-navigation-list" />\n</div>' to equal '<div />'
at Object.assert [as default] (~/node_modules/expect/lib/assert.js:20:9)
at Expectation.toEqual (~/node_modules/expect/lib/Expectation.js:69:26)
at Expectation.toEqualJSX (~/node_modules/expect-jsx/index-dist.js:27:93)
at Test.fn (~/web_modules/Portal/__tests__/index.js:40:56)
at tryCatcher (~/node_modules/bluebird/js/release/util.js:11:23)
at Object.gotValue (~/node_modules/bluebird/js/release/reduce.js:145:18)
at Object.gotAccum (~/node_modules/bluebird/js/release/reduce.js:134:25)
at Object.tryCatcher (~/node_modules/bluebird/js/release/util.js:11:23)
at Promise._settlePromiseFromHandler (~/node_modules/bluebird/js/release/promise.js:489:31)
at Promise._settlePromise (~/node_modules/bluebird/js/release/promise.js:546:18)
at Promise._settlePromiseCtx (~/node_modules/bluebird/js/release/promise.js:583:10)
at Async._drainQueue (~/node_modules/bluebird/js/release/async.js:134:12)
at Async._drainQueues (~/node_modules/bluebird/js/release/async.js:139:10)
at Immediate.Async.drainQueues [as _onImmediate] (~/node_modules/bluebird/js/release/async.js:16:14) |
I am currently using tape and I am considering switching to AVA.
There is just one piece missing atm: https://github.com/atabel/tape-jsx-equals
As you can see
tape-jsx-equals
useextend-tape
to extends tape.Are you open to add support of equalJSX in the core? If not will it be possible to provide a way to easily extends AVA?
The text was updated successfully, but these errors were encountered: