E
E
evg_962017-09-19 07:51:24
JavaScript
evg_96, 2017-09-19 07:51:24

What to read/watch on code testing (JS)?

I have never done automated testing before. Now it seems like the realization has come that it’s time to start already ...
I googled a little, found out that there are many different frameworks, all sorts of TDD, BDD, IT, E2E, etc.
It seems like a popular framework for JS unit tests is mocha.
In general, advise materials in Russian for studying this topic, perhaps specifically on mocha.
Where to start studying this topic at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2017-09-19
@maxfarseer

It's easy to get confused at first. The following helped me:
1) there are test runners (that is, utilities that run tests, in your question this is mocha) and "asserot" libraries - this is something like "assertions" that you will use in tests.
2) all unit tests are nothing more than testing some function for the fact that it will produce a result previously described (by you!) Figuratively: there is a function sum(a, b), you write some code like this:

import { sum } from './my-functions'
ожидаю, что sum(1,3) === 4

if you add some pseudo-library of assertions, it will be something like this:
import { sum } from './my-functions'
import { should } from 'another-assert-library' // should в переводе "быть/являться" 
ожидаю, что sum(1,3).should.be.eql(4) // ожидаю что sum(1,3) будет равно 4

On habré from the latest about mocha, translation of an article from "adhesive tape" , in which, in my opinion, the code is already outdated, and the tests most likely will not pass, but you can read it.
Did not stand aside and learn.javascript.ru with its section about tests

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question