As mentioned in the chapter 4.3 Code Uniformity linter is being used in Penneo, it was also decided to create specific Linter rules for the tests. On top of the already mentioned rules, Jest specific rules were added (https://github.com/jest-community/eslint-plugin-jest):
Disallow disabled tests. Jest has a feature that allows to temporarily mark tests as disabled. It is often used for debugging or creating the actual tests. However before commiting changes to GitHub all tests need to be running.
Disallow focused tests. This rule is very similar to the rule above. Jest can also focus on running only one test which is particularly helpful for debugging a failing test, so all of the tests do not have to be executed while doing that which with a big amount of tests could annoying. This rule ensures execution of all the tests (not only one) on Travis.
Disallow importing Jest. Since the `jest` object is already automatically in the scope of every test file it is unnecessary to import it. Furthermore `jest` object does not export anything anyway. The methods for creating mocks and controlling Jest’s behaviour are part of the `jest` object.
Suggest using `toHaveLength()` to assert object’s length property in order to have a more precise failure message.
Enforce valid `expect()` usage. This rule ensures that the `expect()` is called with a single argument only and that the actual expectation has been made.
Disallow identical titles. Having tests with identical titles within the same test suite may create confusion, especially when one of them fails it is harder to know which one failed and should be fixed.

5.2.2 Testing components

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

Within the wrapping `describe` clause of a components test suite write “Component” within square brackets followed by the components name (e.g describe(Component ComponentName)).
Always start with writing a minimal component test which confirms that component rendered, then test behaviour.
Use explicit `setup()` over `beforeEach()`, so it is clear how the component was initialized in the specific test.
All interaction with external modules should be mocked
Put tests close to the files they test and name test files with a `.test.js` extension.

5.2.3 Testing stores

Within the wrapping `describe` clause of a stores test suite write “Store” within square brackets followed by the store name (e.g describe(Store StoreName)).
Mock every module except the one that is being tested in order for a unit test to operate on a fully isolated unit of code.
Before each test, set up an access to the store’s registered callback. Since the application’s dispatcher is thoroughly mocked the Flux data flow has to be simulated.
Before each test clear the store so it has its initial state for another test.
If helper functions are needed they must be defined outside of tests
Every store test suite must have a test that checks whether a callback has been registered with a dispatcher.
Put tests close to the files they test and name test files with a `.test.js` extension.

5.3 Functional tests
The standards for writing functional UI tests got split up into two parts. First one treats about a recommended way for creating well designed Cucumber tests, the second one talks about good practices and standards that have been followed related to writing WebdriverIO tests.

5.3.1 Cucumber
Using Cucumber with the following practises in the automated functional UI tests ensures that the experience of creating the tests will be successful and that reliable tests would be created.
These practises are the following:
There can only be one feature of the application per feature file, file should be well named so at a first glance it is known what feature it tests

Use customer’s domain language to write stories, so customers (in this case QA team) can get involved in the process of writing stories. Avoid inconsistencies in this matter.

Write declarative features

Avoid conjunctive steps

Reuse step definitions

x

Hi!
I'm Katy

Would you like to get a custom essay? How about receiving a customized one?

Check it out