A
A
Andrey Salnikov2016-05-12 14:40:04
JavaScript
Andrey Salnikov, 2016-05-12 14:40:04

With what help to write tests for the site?

Уже давно читаю надписи типа - не пишешь тесты для сайта ( магазина к примеру ), то ты плохой. И никак не могу понять где про это почитать. И с чего начать. Тоесть можно ли вообще тестировать сайт? Или это говорят только про серверную часть? Если ли какие-то framework'и для такого тестирования? Ну что бы например внес я какие-то изменения в js или частично в HTML. Запустил тест и он... вообщем сказал работает он по старому или сломался. Вроде такие тесты называются end-to-end, да? Вообщем подскажите куда копать по этой теме?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
Котик Антон, 2016-05-12
@Shshzik

jstherightway.org/#testing-tools
github.com/sorrycc/awesome-javascript#testing-fram...

H
hubramubr, 2016-05-12
@hubramubr

You don't write tests - are you a bad programmer?
It depends on the task. Automated testing is a thing. But on inexpensive projects, they do without it.
There are server-side tests, there are JS tests, there are functional tests, there is unit testing. They are all spelled differently and differently.
Well, for example, Selenium is used for tests with user emulation.
And the unit testing technique is usually described in the documentation for the tools used.

X
xfg, 2016-05-12
@xfg

Popular for unit tests
mocha
jasmine
For end-to-end tests
nightwatch
protractor
Yes, you can test both the client side and the server side. On the client side, when writing unit tests, there may be a problem with the DOM, since it is not very clear how to mock such dependencies. Therefore, client side frameworks such as angular promote an approach to writing code in such a way that the business logic is never mixed up with the DOM. Thus, all important business logic can be covered by unit tests, without any problems.
Functional (end-to-end) tests emulate user behavior through a real browser. That is, the end-to-end test presses buttons, fills in fields, follows links. These tests are slower than unit tests. Page layout changes can break them. But they are more high-level, they make sure that the page works exactly as it was supposed to. They do not depend on code, and therefore do not have problems with the DOM, unlike unit tests.
Personally, I only write unit tests. And I don't write integration and functional ones. Unit tests are very fast, they can be automatically run every time the project file is saved. At the same time, they provide an acceptable level of confidence that the project build will work rather than not. If you write all types of tests, you can shoot yourself in the foot. It will be slower. There will be more problems with fixing a bunch of different tests.

X
xmoonlight, 2016-05-13
@xmoonlight

https://github.com/segmentio/nightmare

S
samizdam, 2016-05-13
@samizdam

Read about Selenium - for any programming language there are frameworks based on it.

E
Eugene, 2016-05-17
@evgenktulu

In addition to Selenium, you can also pay attention to PhantomJS and its offspring CasperJS (headless browser testing)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question