erikras / erikras/react-redux-universal-hot-example
Negative server-side tests can't fail.
- Dominant language
- JavaScript
- Stars
- 12.1k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
Server-side tests contain some checks which can't fail if the related code is changed.
Example: widget-load-test.js
```
it('rejects the call', function() {
return load({session: {}}).
then(
()=> {
},
(err)=> {
expect(err).to.equal('Widget load fails 33% of the time. You were unlucky.');
});
});
```
If the widget code is changed so it always passes, this will still pass because the expectation is in the catch block of the test.
I have a branch where I'm changing the tests so they can fail. While doing that, I'd like to refactor all async tests to use async/await as a nice example of what can be done today:
```
it('rejects the call', async function() {
let message;
try {
await load({session: {}});
} catch(error) {
message = error;
}
expect(message).to.equal('Widget load fails 33% of the time. You were unlucky.');
});
```
Negative tests are a little nicer. Positive tests are cut down to 1-2 lines - it's fantastic.
Any objections?
Contributor guide
Assessment
This issue has not been assessed yet.