Comments (34)
Which stack do you prefer? I'd like to try tape, do you have some experience with it?
from react-mdl.
I don't really have much experiences in this.. Would probably have to check what other React repo do in term of tests and use the same frameworks for that...
from react-mdl.
I'd like to help with that. Really want to have tests for this project.
from react-mdl.
@tleunen If you're happy with karma+mocha for testing I can assist in writing tests -- just checking out the package now to potentially use in a project. If I do use it, I'll be more than happy to contribute tests.
from react-mdl.
@nathanmarks sure thanks!
I'm still unsure if karma/mocha is really needed of if we just have to check the output html for each components based on the props we provide.
I don't think we really need to render it in a real browser in this case, because MDL upstream already does this kind of testing to making sure the rendering is correct.
from react-mdl.
@tleunen It doesn't make sense to check rendered html and even check parts of a DOM, but we should test if interactions work correctly.
from react-mdl.
Not sure if shallow render can help with that. MDL works in a browser environment.
from react-mdl.
@nathanmarks Thanks, I think we need some help with tests.
Do you have any experience in writing tests with user interactions?
from react-mdl.
@faergeek Are you talking about simulating real user interactions? I write quite a bit of scripting for headless browsers.
from react-mdl.
Yes, react has test utils to simulate events https://facebook.github.io/react/docs/test-utils.html.
But I'm pretty sure that they're simulating events just for react itself and we probably need something like selenium to test the whole thing.
from react-mdl.
@faergeek I have used selenium a bit and I've got a lot of phantomjs experience.
I think if @tleunen can pitch in and let us know what he sees as in scope for testing here -- we can make a decision on tape/mocha/etc.
I would start by asking ourselves, what is the goal of this package, and what is the best way to confirm that the goal is being reached?
If the goal is to 100% mirror the MDL upstream functionality, perhaps testing render output in different component states (via user interaction) and comparing it to the MDL output is a possibility for tests.
from react-mdl.
@nathanmarks This project is not the mirror of upstream functionality, it's wrapper around it.
Probably we could try to just check the rendered DOM in different states, but I'm not 100% sure that it will be enough.
About testing framework: I suggest using tape as a testing framework because TAP is widely supported standard and we potentially get many integrations for coverage, CI and such things related to testing.
But I have no experience with it.
I'm going to try it out on a smaller project like lib which I didn't publish yet or on one of my private react projects to see how smoothly it goes.
from react-mdl.
I don't think Selenium is needed.
What we just have to make sure is the output of the components based on the props they receive.
Mocha, chai or whatever should be enough.
from react-mdl.
Yes, probably we don't need selenium or even phantom for now.
About "mocha, chai or whatever":
Mocha is a test runner and can't work by itself, it has no assertion library, chai is assertion library that works with mocha.
Tape on the other hand is a standalone tool that runs tests and also provides assertion library, but it needs a reporter probably (standard reporter just outputs raw test data to console, which is not so readable).
from react-mdl.
I'll probably go with Mocha + basic assert (at least for now)
from react-mdl.
Ok, I just told about advantages of tape.
If you still wanna to use mocha, let's use it 👍
from react-mdl.
I'm happy to contribute tests with either of them (tape or mocha).
Tape is super simple and easy to use.
from react-mdl.
If you'd like to use karma and tape, I've started a branch on my fork.
If not, I'll wait until you get your testing approach sorted out before writing more tests
from react-mdl.
I've started to use mocha + React shallow renderer in this PR #84
Again, I'm not sure something complexe with browser testing is required in this case because MDL already does this part to be sure everything is rendered properly across browser.
from react-mdl.
@tleunen I think we should at least use strictEqual
method of assert because assert.equal
uses ==
instead of ===
which is not cool in many cases, especially for tests.
Or just take a look at what @joshq00 did with tape 👍
I still think that it's more readable and just simpler.
We don't need karma though.
But we definitely need code coverage + some utils for simpler shallow rendering + watching for development.
I'm going to make a branch with all of it right now :-)
P.S. I'm also going to look at that cool thing http://speckjs.github.io/
from react-mdl.
@tleunen Take a look at this article about tape https://medium.com/javascript-scene/why-i-use-tape-instead-of-mocha-so-should-you-6aa105d8eaf4
from react-mdl.
About assert
, that's why I started using expect
instead. It gives more utils and better equals.
About tape vs mocha. Some people prefer the former, some other the latter. I chose the latter for no particular reason except it's widely used. I know tape is also well known.
from react-mdl.
Tape is well known, small and predictable, which is important for tests.
I think react and co has popularized unix-way (small tools that each do one task, do it well and can be integrated vs do-anything combines) in frontend and it's good ;-)
I don't know the reason why mocha has no assertion library, but have many rarely needed things, like tons of reporters etc. It's bad separation IMHO.
And just look at tape, it's much more readable anyway.
from react-mdl.
I would actually argue that less assertion functions is better.
When I used mocha and chai, learning the million different asserts was time consuming. Writing tests, I was constantly referencing the docs
Sticking to just a few forces you to simplify what you're testing. I try not to use deep equals or any of those. As much as I can, testing with .equal
keeps them very clear about what I'm expecting and makes me better design my tests
from react-mdl.
@tleunen What if we at least agree on using only simple assertions as @joshq00 said?
from react-mdl.
What's wrong with expect
? It's easy to use.
from react-mdl.
Nothing's wrong.
Let's just agree to not use some assertions like expect(3).to.be.not.ok
and instead use expect(!3).to.equal(true)
, for example.
from react-mdl.
Not sure to see the point here. I'm using what feels the best to use for every usecase.
from react-mdl.
I mean it takes time to search docs for method that "fits" and then search what exactly method does when reading.
I did it before, it annoys. Looks logical only at the first time.
from react-mdl.
My question is what is gained when using the long-chained language asserts?
expect( obj ).to.have.property( '_id' ).that.is.a( 'string' )
does not give any added value over
assert( typeof obj._id === 'string' )
But it does make it take longer to write the tests.
"Do I use .that.is.a.number
? or is it .that.is.a( 'number' )
? I forget... check the docs"
from react-mdl.
@joshq00 Exactly 👍
from react-mdl.
It's not that long. Take a look https://github.com/mjackson/expect
And it gives you readability.
from react-mdl.
Okay, that version is much better than embedded in chai 👍
from react-mdl.
I made a few tests with jsdom this morning.. Well, it's a lot faster than Karma, but a few things are not implemented in jsdom (like html5 validity inputs) which prevent some tests to be done :/
from react-mdl.
Related Issues (20)
- Library request on CDNJS HOT 3
- The prop `target` is marked as required in `Menu`
- React-MdL Dialog Not working in firefox and safari HOT 2
- Checkbox visibility
- Button ripple effect bug!?
- [TextField] Grey border-bottom doesn't disappear when field is clicked. Blue doesn't cover grey correctly. HOT 1
- DataTable: Is there any option to handle onSelectionChanged with out enabling selectable
- Should I use this project or react-toolbox? HOT 1
- Slider Tick Increments HOT 1
- Fix Circle CI and Codecov badges HOT 2
- [Typescript] Can you change this project to typescript ?
- [DataTable] accept nested objects in "rows" array HOT 1
- TypeError: Cannot read property 'upgradeElements' of undefined
- Where is the source code of react-mdl templates HOT 1
- how to get callback of click event on every single row in datatable
- Dialogs with input fields on mobile devices
- too many css files for WebStrom HOT 3
- 0
- Archive the repo? HOT 1
- "Uncaught Invariant Violation: Maximum update depth exceeded" in DataTable property onSelectionChanged Again
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-mdl.