question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better tests and code organization

See original GitHub issue

I mean, we already have few issues because the way the whole code is written - I’m talking for the GENTLY thing at first line of each file ( #337 ). Tests are very confusing and not so easy to maintain. Switching to something more meaningful for whole community would be great - both for us, newcomers and new contributors.

And I’m not talking to switch to something fancy and shitty like AVA or whatever. But the whole testing organization should be changed and rewritten:

  1. mocha - nah… too big code, shit and in bonus: globals; no thanks (self pref. i stopped using it, used it for about few months when i enter in nodejs - I don’t see fit using it soon after that. It is not just a selfpref. it is too big with no reason)
  2. ava - mega big, mega shit, too fancy. selfpref: just seeing a very little bit sense some to use it only if project is huge/enterprise
  3. testit - small, compact, using promises and support nested groups and tests (needless); selfpref: used it through my thin wrapper assertit for 1 year - seems good in most cases, but has bad debugging experience
  4. mukla - absolutely thin with support for streams, callbacks, promises, child processes, async/await and sync tests (ran in parallel), no support for nested groups and tests (enforce atomic tests, if test suite is huge separate it to files), meaningful testing mocha/tape/testit-style using it from 3 years. It is absolutely stable and debugging is cool (has some edge cases that sucks, but it is because the architecture) - at least has clean stacktraces - 1-2 meaningful lines max. But i’m releasing v1 soon (even it is written i’m just blocked because other packages and switching workflow tools). Compared to the other similar testing libs is very good and almost 1:1 (porting from mocha-style + assert to mukla is for ~1min) without the cost for huge install times and huge deps.

I have pretty good experience about testing and building core blocks of such tools. I have written a few testing libs few times. And I always try to stay to standards and conventions, so to not have learning curve. In the case with mukla it is just enough to switch it with test or just make var it = require('mukla'). I just have few ideas for different API approaches and this can be seen in the v1 issue.

mocha

var assert = require('assert')

it('foo bar', function (done) {
  assert.strictEqual(1, 2)
  done()
})

mukla

var test = require('mukla')
var it = test // main export is function
var assert = test // mukla exposes all `assert` methods

it('foo bar', function (done) {
  assert.strictEqual(1, 2)
  done()
})

With easy migration path mukla v1 (mocha-style) -> gruu v1 (compat layer/mix of tape-style and mukla/mocha-style) -> asia v1 (ava/tape-like).

But anyway. I may gone too offtopic, but hope it make sense.

So in short, if you want forget all I said previously, but we need to change two things - 1) rewrite tests, using some meaningful lib and something like superagent; 2) fix the GENTLY thing

/cc @badeball @pornel (sorry for the typos if any, kinda dyslexia ;d)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
GrosSacASaccommented, Nov 27, 2019

I’ll have a look at the tests at some point. We could also use jasmine.

0reactions
tunnckoCorecommented, Jan 29, 2020

Most of the things are done. Need only to switch the test runner (to Jest + superagent/supertest) which is kind of easy thing too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unit Tests, How to Write Testable Code, and Why It Matters
We will discuss what makes code hard to test, which anti-patterns and bad practices we should avoid to improve testability, and what other...
Read more >
Unit Testing Best Practices: Organization & Test Data
These are some best practices on Test Organization and Test Data. ... after the unit of work or entry point of the code...
Read more >
The Benefits of Thoughtful Code Organization on Testing
The Benefits of Thoughtful Code Organization on Testing. Exploring how good code design and organization can bring practical benefits, including ...
Read more >
Unit Testing Best Practices: 9 to Ensure You Do It Right
Do you know any unit testing best practice? In this post, you'll learn nine of them so you can get started the right...
Read more >
project structure - What's the best way to organize our unit tests
The aim is to measure what parts of code are exercized by your tests, so that you can see code that is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found