Basic mocha and chai boilerplate

Boilerplate on Github.

Couple days ago I was asked to write very basic API tests for a project. That project uses javascript and obviously would be right to use same language for testing. Few engineers from that project said they have experience with mocha and chai . So, we decided to use this stack in tests, though it’s not an edge stack (like jest for example).

Boilerplate supports Typescript and CI (Gitlab/Github). As example there is one test for GitHub API.

If you need something very basic and easy to start writing javascript tests give that boilerplate a chance.

Negotiations (introduction)

First video of the lecture tells that negotiations it’s not only business word phrase. Basically it’s any dialogue we have, like at market, at school even home with partner.

Four main principles of any negotiation:

  1. Don’t feel necessity. Don’t be a hostage of necessity. We need to distinguish necessity and wish. Like food, water it’s necessities, when new iPhone or contract with client it’s wish. You can live without that contract.
  2. Each side has right to say “no”. Even on the last steps of project. But, when someone tells you “no”, don’t hesitate to ask why.
  3. Despite you are playing on your own side, first thing you need to care it’s client’s benefit. What that client will get from a cooperation with you.
  4. Don’t be a superman (actually I don’t agree, but I will)

Visualization, principles of visualization

Lecturer of that section Tanya discovers principles of visualization. She answers to question “How to visualize data and show what it hides”.

As the raw material for most visualization we use tables or lists. Visualization allows us to look it from general view, from big plan. And from that position we can find topics we didn’t see before. Tanya brings this picture as an example. As you see it’s a map of earthquakes throughout world. I believe it started as plain table, but the visualization reveals a big picture. Now we can say majority of earthquakes happens on the edges of tectonic plates.

Continue reading “Visualization, principles of visualization”

Give something up

According to Cambridge English Dictionary “give something up” means to stop doing a regular activity. For example I drink coffee everyday. So, I can say “I give up drinking coffee”. You can hear that phrase when people talk about quitting a habit. Like quit smoking, quit drinking alcohol.

Continue reading “Give something up”

What is interface?

I’m reading next lecture from Bureau course of UI Designer. I want to highlight some points from there. Answering to the question what is interface Ilya mentions Jef Raskin’s book and definition from the book:

Interface it’s a way you to interact with a product. Actions you do and return you get.

Every interface has physical personalization. So Ilya introduces his own definition:

Interface it’s the rules of game and their physical personalization.

Ilya says if you want to construct interface it’s not enough just to follow logic. You need to know more, and rely on knowledge about principles of psychology, memory, how we interpret visual forms.

Continue reading “What is interface?”

Come across (phrasal verb)

Macmillan dictionary describes 3 possible definitions of that phrasal verb:

  1. to meet someone, or to find something by chance
  2. if someone or something comes across in a particular way, you have a particular opinion of them when you meet them or see them
  3. if something such as a feeling or idea comes across when you speak, you make it very clear to people
Continue reading “Come across (phrasal verb)”

The rule of internal and external

The rule of of internal and external it’s a special case of proximity principle in visual design. Simply saying all external parts must be bigger than internal. For example distance between letters must be bigger than distance between lines of letter, distance between words must be bigger than distance between letters in words.

Here few examples of breaking that rule and I tried to fix it.

Continue reading “The rule of internal and external”

Next level of coding courses

Recently I’ve got a message from a coding school. They offer two options to go through their courses. One is cheaper, but without review. You are simply watching prerecorded videos. Other one includes exercises and code reviews.

So, I come up with idea of coding courses where content like video and exercises are open and free for everyone. But, coding review is a paid function. And you can choose a person who will review your code. And price of review will be different. Like you want to hire someone who is more detailed in review or who has some very rare knowledge. You decide.

You choose a reviewer for particular exercises. Exercise may have different levels, like to reverse a string or create a web server. Also reviews can be plain text or recorded video with explanations.

Sure, reviewers have rating and reviews 😉 What do you think about the idea?

Test automation based on Ruby stack

Boilerplate can be found at Gitlab

So, first things first, please clone the repository. It includes all required tools, you can start writing tests at once. But, if you’re greedy for details, read on.

Dockerfile

I was not a fan of Docker technologies. I guess it’s because all my development was around Ruby language (standard MRI). And I had all versions installed on my computer. But, then my friend asked me to help him with some PHP. After 20 minutes of trying to install the correct version of the language and all libraries, I took Docker and configured everything there. From that point all my projects support Docker.

It’s all for Docker. Ping me if you know how to improve.

Ruby stack. Gems.

It’s time to speak about our ruby business. Here the list of libraries and their assignments:

  1. capybara – what we call “sugar” or DSL over different drivers, like Selenium. Without capybara you can’t write something like visit ‘moduscreate.com’. But, if you wish you can write your own layer; it should be an interesting adventure.
  2. cucumber – all things around BDD, like Gherkin language support e.t.c.
  3. webdrivers – webdrivers gem will download the last version of chrome/firefox/edge driver if a certain version was not defined. In my case it didn’t play well with Alpine. After this article definitely i will sit and find out what’s the problem.
  4. rspec – well known library for every ruby developer. Added to here in order to have these nice readable expectations.
  5. byebug – it’s a debugger. Developing new tests I prefer to run browser in normal mode, stop tests when a certain page is opened and play with elements on the page.
  6. site_prism – library which provides easy integration with the Page Object pattern. Using site_prism makes your tests easy to change, and decouples logic of tests from page

All required configurations for these libraries are in the features/support directory.

Gitlab CI

Next stop is Gitlab CI. Well as i said this boilerplate is quite opinionated. Last 4 years I have landed all my projects on Gitlab. And they were first (compared to Github) with CI/CD system. Even now when we have Github Actions I think Gitlab CI has far more features. But, I understand maybe it’s because Github Actions still is young.

So, as in case with Dockerfile I will explain all lines. Let’s dive in .gitlab-ci.yml.

How can I use Gitlab CI, if I don’t even have a deploy process?  Or you have another repository which is not connected with e2e tests. Here two examples:

  1. If you don’t have a deployment process, you can configure the schedule for your e2e tests repository. For example every 2  hours.
  2. If you have a deployment process. It’s even cooler, you may trigger your e2e tests repository example (read more about multi-project pipelines):

Where are the tests?

So, all preparations are made. Now we can check out some examples in the features directory. There I test moduscreate.com to have some cool vacancies (we always have them). And sometimes there are test automations engineers vacancies.

How to use it?

Please check Readme at corresponding repository. Shortly speaking you can launch tests on Docker or on your host machine. Running tests locally you can view all actions visually in the browser, it helps to debug existing or create new tests.

Last words

I made this article because I use this boilerplate and wanted to share my thoughts. If you are a junior, you may find this template as a good starting point. You may hear “ruby is dead” i’ve been hearing this for the last 4-5 years. It’s not important which language you use, more important how good you are with it. Ok, I don’t know why I’m delaying you. Fork and try it out.

Структура клиентского кода в Rails приложениях

У меня есть идея о том как распределять js/coffee файлы в Rails приложениях, тех что не SPA. Правда пока не пробовал его в бою) но тем не менее мне, он кажется перспективным.

Основной посыл в том чтобы браузер загружал и использовал только те скрипты, которые используются в рамках одного action. Точнее даже так один action – один js файл.

Continue reading “Структура клиентского кода в Rails приложениях”