@
@
@Richswitch2018-01-06 21:24:17
JavaScript
@Richswitch, 2018-01-06 21:24:17

How to properly add unit tests to a project?

Hey!
I can't figure out how to properly organize module testing for a web application. I am doing this for the first time and I can not decide on the structure that will be correct.
Abstraction of my project structure:

app
-index.js
----graphql
       |--schema.js
       |--mutation.js
       |--query.js
----pages
       |--main.js
       |--other.js
----public
       |--another.js

5a5112928c5e1948857808.png
Now I do it this way:
app
-index.js
-index.test.js - сюда буду реквайрить остальные .test. файлы
----graphql
       |--schema.js
       |--mutation.js
       |--query.js
       |--schema.test.js
       |--mutation.test.js
       |--query.test.js
----pages
       |--main.js
       |--other.js
       |--main.test.js
       |--other.test.js
----public
       |--another.js
       |--another.test.js

5a5112f718e74046662385.png
Those. I just copy each separate file in which I will do tests for functions. I do this so that extra code does not get into production.
But I doubt very much that this approach is correct.
In the future, I will build the project in production as a webpack, where all files with the .test..
Question:
How to properly add unit tests to a project?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question