В ходе доклада мы обсудим такие виды тестирования как:
- юнит тестирование,
- тестирование верстки,
- e2e-тестирование,
- тестирование производительности для FE
Также мы коснемся таких фундаментальных вещей, как:
- Что такое F.I.R.S.T
- Где заканчивается ответственность разработчика и начинает - ответственность QA инженера
- Как договариваться с бэкенд разработчиками
- И конечно, почему тесты нужны.
2. Nikita
Galkin
Love and Know:
▰ how to make developers and business happy
▰ technical and process debt elimination
Believe that:
▰ Any problem must be solved at the right level
▰ Software is easy. People are hard
▰ A problem should be highlighted,
an idea should be "sold",
a solution should be demonstrated
Links:
Site GitHub Twitter Facebook
2
17. Test structure
Arrange/Given – setup data and
dependency.
Act/When – run the code.
Assert/Then – check expectation.
Cleanup – remove side effects and clean
data.
17
18. Without structure
18
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present',
function() {
assert.equal(-1, [1,2,3].indexOf(4));
});
});
});
19. With structure
19
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present',
function() {
// arrange
const arr = [1,2,3];
const el = 4;
// act
const index = arr.indexOf(el);
// assert
assert.equal(-1, index);
});
});
});
23. ▰ A developer should not hesitate to run the tests as
they are slow.
▰ All of these including setup, the actual test and tear
down should execute really fast (milliseconds) as you
may have thousands of tests in your entire project.
run tests in parallel with ava or jest
using mock and stabs
Fast
23
26. ▰ A test method should NOT depend on any data in
the environment/instance in which it is running.
▰ Deterministic results - should yield the same
results every time and at every location where
they run.
▰ No dependency on date/time or random functions
output.
▰ Each test should setup or arrange it's own data.
Repeatable
26
27. Repeatable
27
it('should write to log',(done)=> {
// @todo Fix on travis file writing
if (process.env.TRAVIS) {
return this.skip()
}
// main logic ...
}
31. Linting
31
▰ Code style documentation
▰ Review code,
not code style
▰ Autochecking best
practises
32. Eslint
32
▶ eslint --init
? How would you like to configure
ESLint? Use a popular style guide
? Which style guide do you want
to follow? (Use arrow keys)
❯ Google
Airbnb
Standard
33. ESLint v4.12.0 released
33
New Rules
▰ implicit-arrow-linebreak. This rule aims to
enforce a consistent location for an arrow
function containing an implicit return.
Autofixable Rules
▰ sort-vars. At present, it will only sort
variables with no initial value or a literal
initial value, in order to avoid potentially
changing the order of function calls.
50. e2e testing
50
▰ As visual testing use real backend
▰ Focus on UX, not on UI
▰ Mark your elements for better tests
▻ We use data-e2e attribute for that.
▰ Angular has e2e ready framework
protractortest.org