Simplify communication with APIs using Axios | IT's time to talk #4

00:00 → 00:03

Modern IT world offers variety of testing

00:03 → 00:08

tools that can increase the efficiency of quality assurance teams.

00:08 → 00:10

Today, we will be talking with Paweł Leszczyński,

00:10 → 00:13

who is test who is a TRester at Merixstudio about Axios,

00:13 → 00:17

a tool that is increasing the efficiency of our team and

00:17 → 00:21

also helps us perfect tests that we perform.

00:21 → 00:22

It's time to talk.

00:22 → 00:26

A Merixstudio show about technology and business.

00:32 → 00:35

Hello, Paweł. How are you?

00:35 → 00:38

Hello. Thanks a lot. So I'm fine. How are you?

00:39 → 00:40

Fine. Thank you.

00:40 → 00:43

Paweł, if you could introduce yourself in a couple of words,

00:43 → 00:45

tell us what are you doing at Merix.

00:45 → 00:47

What is your role?

00:47 → 00:49

What and what kind of projects do you work?

00:51 → 00:54

Sure. So I'm a senior quality assurance specialist.

00:55 → 00:57

This is one of my roles.

00:57 → 01:02

The second one is I'm a competency lead.

01:02 → 01:02

Okay.

01:02 → 01:07

So I'm focusing on technology.

01:07 → 01:11

I'm focusing on general strategy and

01:11 → 01:14

quality assurance department.

01:15 → 01:20

I also help my coworkers if

01:20 → 01:24

they have any problem in their in their projects,

01:24 → 01:28

I I help them with some technical decisions. Alright.

01:28 → 01:32

I'm I also work with our engineering

01:32 → 01:34

managers to

01:37 → 01:42

to set some technology strategy

01:42 → 01:46

in general connected with other teams with

01:46 → 01:48

front and with back end with DevOps.

01:48 → 01:51

So, yeah, that's that's it.

01:52 → 01:56

Right now, I'm in very interesting project.

01:56 → 02:01

We are focusing in this project on

02:01 → 02:03

only front end side.

02:03 → 02:06

The back end is

02:06 → 02:10

is sent by by the client,

02:10 → 02:12

by client's team.

02:12 → 02:16

And we creating very

02:16 → 02:18

complicated charts.

02:18 → 02:20

We gather this back end.

02:20 → 02:24

We have a lot of front end tests.

02:24 → 02:28

So Ui testing, screenshot testing.

02:28 → 02:32

It's pretty challenging to be sure that this

02:32 → 02:34

complicated front end is

02:35 → 02:36

working

02:37 → 02:40

on the same high level all the time.

02:41 → 02:43

Alright then. Thank you very much for this introduction.

02:43 → 02:46

Today's episode is about Axios,

02:46 → 02:50

and I know that Axios has been replacing some

02:50 → 02:53

other tools that we've been using in the recent past.

02:53 → 02:57

If you could tell me what the if you could introduce us first

02:57 → 03:00

to this tool, what is it all about,

03:00 → 03:03

why testers love it or not,

03:03 → 03:08

and why it has been so widely introduced in our projects?

03:08 → 03:09

Sure.

03:09 → 03:13

So Axios, actually, is a very

03:13 → 03:15

simple library.

03:15 → 03:18

And the the main

03:18 → 03:22

the main reason why we use it is

03:22 → 03:26

that we can send a request to the back end in

03:26 → 03:29

very simple and not complicated way.

03:29 → 03:31

And this is one reason.

03:31 → 03:36

On the other hand, it has a lot of useful

03:36 → 03:38

things already implemented.

03:38 → 03:43

For instance, we can easily check the response.

03:43 → 03:46

We have timeouts implemented.

03:47 → 03:50

We have async await

03:52 → 03:57

implemented in in working with this library.

03:58 → 03:59

And

03:59 → 04:04

maybe it's also important, our front end developers

04:04 → 04:07

Also use this library.

04:07 → 04:11

And thanks to that in case of any problems,

04:11 → 04:14

in in case of any concerns,

04:14 → 04:18

we can discuss with them some use cases or

04:18 → 04:22

some solutions to to the problem.

04:22 → 04:26

But this is only Axios.

04:26 → 04:27

Without

04:28 → 04:31

other libraries, it can be hard to

04:32 → 04:36

to perform API test.

04:37 → 04:38

Yeah.

04:38 → 04:38

Alright then.

04:38 → 04:42

Aside from Axios, we also use Chai and Mocha.

04:42 → 04:44

Can you say a few words about it?

04:44 → 04:47

I just hope that you will ask about it,

04:47 → 04:49

and that's good.

04:49 → 04:50

That's good.

04:50 → 04:52

Because access, like I mentioned,

04:52 → 04:54

it's only the simple library.

04:54 → 04:57

We can send and get responses.

04:57 → 04:59

So

04:59 → 05:02

we only execute the sending.

05:02 → 05:02

But Okay.

05:02 → 05:06

Mocha and Chai gives us possibility to perform

05:06 → 05:11

automated API tests in general in

05:11 → 05:12

because

05:13 → 05:16

Mocha gives us possibility to run those tests.

05:16 → 05:20

It also give us some test structure.

05:20 → 05:23

But Chai is

05:24 → 05:27

a library which gives us

05:28 → 05:30

some set of assertions.

05:30 → 05:36

And so assertions, this is a very simple check.

05:36 → 05:40

For instance, if in the response,

05:40 → 05:44

this element is a number or is a string or

05:44 → 05:47

if Mike Liszewski is a sales.

05:47 → 05:50

And if it's true, everything is working,

05:50 → 05:55

and our our tests are positive,

05:55 → 05:57

are success.

05:57 → 05:59

In case of any problems,

06:00 → 06:04

our child library will will say that, right,

06:04 → 06:07

this part of the code fails,

06:07 → 06:12

and we are sure which part of code is not working.

06:12 → 06:15

And so access, of course, is very important,

06:15 → 06:17

but without mock and child,

06:17 → 06:21

it would be not possible to perform API tests.

06:21 → 06:22

Okay then.

06:22 → 06:24

And what

06:24 → 06:28

kind of typical tasks you can perform using Axios?

06:30 → 06:34

So Axios combined with Mocha and Chai,

06:34 → 06:37

this is a great tool.

06:37 → 06:40

This is a great framework because we created,

06:41 → 06:43

I can say, our own framework.

06:43 → 06:45

We can perform API tests,

06:45 → 06:48

automation API tests.

06:48 → 06:53

Thanks thanks to this framework, we can

06:53 → 06:55

we can cover

06:56 → 06:59

our API tests.

06:59 → 07:00

I mean,

07:02 → 07:07

those all methods which are post get patch and delete.

07:07 → 07:11

So the most basic and the most important

07:11 → 07:16

API methods which were created by by our back end developers.

07:16 → 07:22

It's those old things can be simply

07:23 → 07:26

covered by by Axios.

07:28 → 07:29

Yes.

07:31 → 07:32

Alright then.

07:32 → 07:36

And we have recently replaced Cypress. Yes?

07:36 → 07:39

Because we introduced Axios into

07:39 → 07:42

our methodology of working, like you said,

07:42 → 07:44

into our framework.

07:44 → 07:48

Access is used com combined with Chai and Mocha,

07:48 → 07:50

but we have replaced Cypress.

07:50 → 07:52

The first question will be why?

07:53 → 07:54

Sure.

07:54 → 07:58

So maybe a few words about the past.

07:58 → 08:01

So it was really easy for us to

08:01 → 08:05

to perform and execute all all the

08:05 → 08:09

tests with one tool, which Cypress.

08:09 → 08:12

It's really great for end to end testing,

08:12 → 08:16

for UI testing, and it gives us also some

08:16 → 08:19

possibilities to perform API test.

08:19 → 08:20

Alright.

08:20 → 08:24

But to be honest, it's not really

08:24 → 08:26

prepared for API test.

08:26 → 08:30

There were a few things which were a problem

08:30 → 08:34

in our process, in our situation.

08:34 → 08:38

I can mention maybe the three more important things.

08:38 → 08:43

So Cypress needs needs always to

08:43 → 08:44

use a browser.

08:44 → 08:49

So to send simple requests

08:49 → 08:51

and getting responses,

08:52 → 08:54

It's not really, you know,

08:54 → 08:58

important to to run browser all the time.

08:58 → 09:01

We can do it with Node. Js engine.

09:01 → 09:04

And but Cypress require it.

09:04 → 09:08

It is built in the Cypress technology

09:08 → 09:11

to run browser every time.

09:11 → 09:14

And this point is connected with the second point,

09:14 → 09:16

so the performance.

09:16 → 09:19

Because of it, because we needed to

09:20 → 09:23

to run browser, over and over,

09:23 → 09:26

and the performance were pretty bad.

09:26 → 09:31

And and there were some projects where

09:31 → 09:33

we had hundreds of tests.

09:34 → 09:39

And when we perform our tests with Cypress,

09:41 → 09:44

those tests took really long time.

09:44 → 09:47

It was fifteen minutes, thirty minutes,

09:47 → 09:48

sometimes even an hour.

09:48 → 09:53

So it was really hard to work with such performance.

09:53 → 09:55

In case of Axios, it's not an issue.

09:55 → 09:59

It's much lighter library.

09:59 → 10:04

And thanks to that, our tests are much faster, and

10:04 → 10:07

our developers can can

10:08 → 10:11

get information about their work

10:12 → 10:13

much faster.

10:13 → 10:16

They can fix their issues

10:16 → 10:19

better and easier, simply.

10:19 → 10:22

The third point is really technical.

10:22 → 10:26

We can maybe later paste some example of

10:26 → 10:33

code, but Cypress does not support

10:33 → 10:34

async await.

10:36 → 10:41

And because of that, the code is less readable.

10:41 → 10:45

So to sum up this point a little bit,

10:46 → 10:51

In my opinion, it's much cleaner and better

10:51 → 10:55

to write code with access than in Cypress.

10:56 → 10:57

Alright then.

10:57 → 11:00

And so aside because we've been

11:00 → 11:03

talking a lot about the benefits of using it,

11:03 → 11:04

are there any, let's say,

11:04 → 11:08

risks or disadvantages of using this particular

11:08 → 11:12

library comparing to other tools that

11:12 → 11:13

are currently available?

11:15 → 11:18

I think that maybe it's not in risk,

11:18 → 11:20

but It's really easy.

11:20 → 11:21

It's really simple tool.

11:21 → 11:25

It's it was our decision that

11:25 → 11:30

after Cypress, which is a really a really big

11:30 → 11:33

tool, it they gives us a lot of libraries.

11:33 → 11:37

We decided to use access child mocha because those three

11:37 → 11:39

libraries are pretty small.

11:39 → 11:45

And thanks to that, we can we can use it in a way that we want.

11:45 → 11:47

We have no

11:48 → 11:51

no problem that framework

11:51 → 11:58

requires some some particular type of work with it.

11:58 → 11:59

So

12:00 → 12:03

the risk is it's pretty small,

12:03 → 12:07

but the benefit, at the same time is that you can add

12:07 → 12:08

other libraries.

12:08 → 12:11

If you want, you can extend

12:12 → 12:13

your framework.

12:13 → 12:18

And thanks to that, you are more flexible, in my opinion.

12:18 → 12:18

Okay.

12:18 → 12:22

You mentioned that it it's simple,

12:22 → 12:25

and you can eventually add an additional libraries,

12:25 → 12:28

but it sounds to me that it has its limits.

12:28 → 12:30

Is it, let's say,

12:31 → 12:34

unrecommended to use Axios in bigger projects?

12:34 → 12:38

Or, for example, is it not recommended to use Axios in

12:38 → 12:42

projects requiring, for example, higher

12:42 → 12:46

security standard, OS, or so on?

12:47 → 12:49

No. It's not an issue.

12:50 → 12:52

You know, API testing, in my opinion,

12:52 → 12:54

is not very complicated.

12:54 → 12:58

Access gives us those possibilities combined with

12:58 → 12:59

trial and mock up.

12:59 → 13:02

And so it's not an issue.

13:02 → 13:05

I think that sometimes in some complicated cases,

13:05 → 13:07

you need to,

13:08 → 13:09

for instance,

13:10 → 13:13

write a really a lot of codes to achieve something.

13:13 → 13:17

Sometimes it's easier to install the

13:17 → 13:21

external library, and thanks to that,

13:21 → 13:23

do it faster and better.

13:23 → 13:27

And this is only concern that sometimes you need to be aware

13:27 → 13:29

that you not have,

13:30 → 13:31

every

13:31 → 13:35

possible comment, or every possible shortcut.

13:35 → 13:38

Alright. And for instance, you can install Lodash.

13:38 → 13:43

We've give you which gives you a lot of, external commands,

13:43 → 13:45

and it can speed up your work.

13:45 → 13:48

But like I said, it's up to you,

13:48 → 13:50

thanks to the simplicity.

13:51 → 13:52

Okay.

13:52 → 13:54

And are there any, let's say,

13:54 → 13:57

industry related limitations that we we would need to take care of?

13:57 → 14:01

For example, we shouldn't work with medical industry

14:01 → 14:03

or, for example, energy industry.

14:03 → 14:05

Are there, let's say,

14:05 → 14:08

any debt kind of limitations that we should be aware of?

14:10 → 14:10

No.

14:10 → 14:14

If our API is a standard one

14:15 → 14:16

It's not an issue.

14:16 → 14:20

We can cover really complicated cases.

14:20 → 14:25

The only concern, it's the, I mean,

14:25 → 14:27

the general issue, in my opinion.

14:27 → 14:29

So

14:30 → 14:33

from my perspective, in ninety five percent of cases,

14:33 → 14:37

it's the benefit of writing those tests,

14:37 → 14:41

automation API test is is great.

14:41 → 14:43

The only

14:44 → 14:48

the only case the only cases which comes to my

14:48 → 14:50

mind is when project is very,

14:50 → 14:54

short and you have no budget,

14:54 → 14:56

probably,

14:57 → 15:01

the benefit from writing API test

15:02 → 15:04

will not come very quickly.

15:04 → 15:08

Will come after, I don't know, two months, for instance, or three months.

15:09 → 15:14

There is a very beautiful chart which gives which shows us

15:15 → 15:17

which show with us.

15:17 → 15:19

But

15:19 → 15:23

after some time, after two or three months,

15:23 → 15:27

we can cover regression with those automation tests.

15:27 → 15:29

We can

15:30 → 15:34

we can focus on all the other things.

15:34 → 15:36

And during that time,

15:36 → 15:40

those automation tests are checking

15:40 → 15:42

our back end developers.

15:45 → 15:46

Yes.

15:46 → 15:47

Alright then.

15:47 → 15:50

Because I know that in general,

15:50 → 15:54

it it's it's, let's say, like,

15:54 → 15:58

a common knowledge that API tests is like an investment.

15:58 → 15:58

Yeah.

15:58 → 16:01

If the project is relatively small,

16:01 → 16:04

then software development team is neglected.

16:04 → 16:07

However, if we want to build something, let's say,

16:07 → 16:12

bigger and more complex where we will have, let's say, more inquiries,

16:12 → 16:15

more communication coming through through the API and so

16:15 → 16:18

on, then it's, let's say, expected and even recommended,

16:19 → 16:23

to perform API test because this may limit the regression.

16:23 → 16:27

So the volume of tests and cleaning up

16:27 → 16:29

that will be coming afterwards.

16:29 → 16:30

Yes?

16:30 → 16:32

So it's not recommended for small projects,

16:32 → 16:34

but for medium projects and especially big projects,

16:34 → 16:38

it's like a investment which will be returned,

16:39 → 16:40

so to speak.

16:40 → 16:41

Okay.

16:41 → 16:46

You mentioned that Axios is a relatively simple

16:46 → 16:47

library to use.

16:47 → 16:47

Yeah?

16:47 → 16:49

And

16:49 → 16:53

and it requires being combined with other tools,

16:53 → 16:57

but general itself, it's quite easy.

16:57 → 16:59

What is the entry level of using it?

16:59 → 17:03

Do you need to be second Pablo Leszczyński

17:03 → 17:07

having thirty years of experience in in

17:07 → 17:11

software in order to make a good use of it?

17:11 → 17:14

Or what is, let's say, the minimum, let's say,

17:14 → 17:19

knowledge weight of a person that would that could come up

17:19 → 17:21

with a benefit within the project from using it?

17:22 → 17:23

Sure.

17:23 → 17:24

So

17:25 → 17:30

in my opinion, it will be really nice to have some experience in testing in

17:30 → 17:34

general to have knowledge what should be covered,

17:34 → 17:37

which test cases are

17:37 → 17:41

really crucial and required to cover,

17:41 → 17:45

which are maybe some kind of nice to have.

17:45 → 17:49

It will be really useful.

17:49 → 17:51

It will be really useful knowledge

17:51 → 17:55

to start working working with Axios, in my opinion,

17:55 → 17:58

will be also useful JavaScript knowledge.

17:58 → 17:59

Okay.

17:59 → 18:04

So some basics, it's

18:04 → 18:07

not really complicated to start with Axios,

18:07 → 18:10

but in my opinion, the general

18:10 → 18:14

knowledge about JavaScript will be really useful.

18:14 → 18:18

And in general, you should know how those,

18:18 → 18:24

libraries are are working, how to perform

18:26 → 18:29

how to send this request with Axios,

18:29 → 18:32

how to check some assertions with Chai.

18:32 → 18:36

But in our company, those last things which

18:36 → 18:40

I mentioned, so this Axios mock up Chai knowledge is not an

18:40 → 18:43

issue because we have a boilerplate.

18:43 → 18:44

And Okay.

18:44 → 18:47

This entry level, I think,

18:47 → 18:51

is lower because we gives us a lot of knowledge to

18:51 → 18:54

our to our QA specialist.

18:54 → 18:56

Okay. You mentioned boilerplate.

18:56 → 18:59

Does it mean that we are able to do those tests a

18:59 → 19:02

little bit faster than other companies?

19:03 → 19:06

Yes. In my opinion, exactly.

19:07 → 19:10

Because we created boiler boilerplate to

19:11 → 19:16

gives our quality assurance specialist and knowledge how

19:16 → 19:17

to start with those tests.

19:17 → 19:22

We have already implemented some continuous

19:22 → 19:24

integrations setup.

19:24 → 19:28

We give some simple commands,

19:28 → 19:30

which are already implemented.

19:30 → 19:34

In my opinion, we saves tens of hours

19:34 → 19:36

at the beginning of projects.

19:36 → 19:38

Tens Thanks to the solar plate.

19:38 → 19:39

We can copy it,

19:40 → 19:43

paste it to our new project.

19:43 → 19:47

And after some modifications, we can start working with it

19:47 → 19:51

in new project, and we save this

19:52 → 19:54

time at the beginning because

19:54 → 19:56

this this the whole setup

19:56 → 20:01

project is always time consuming.

20:01 → 20:04

In here, I think that we saved some of it.

20:04 → 20:06

Alright then. So it's good to know.

20:06 → 20:09

Butler police are usually related to front end. Yeah.

20:09 → 20:13

Like, dashboard screens and so on.

20:13 → 20:15

And as I can see, we can, let's say,

20:15 → 20:20

simplify or automate the repetitive work

20:20 → 20:22

that is also taking place in testing.

20:22 → 20:25

Okay then. Pavel, thank you very much for this.

20:25 → 20:27

Do you have, let's say,

20:27 → 20:29

any final thoughts that you would like to share,

20:29 → 20:31

some ideas, some recommendations to the market?

20:31 → 20:33

As you know, we work with logistics.

20:33 → 20:35

We work with renewables.

20:35 → 20:37

We work with facility management,

20:37 → 20:39

with financial companies,

20:39 → 20:43

people who basically have higher demand for data

20:43 → 20:47

exchange, for data display, and also to for security of that data.

20:47 → 20:50

So any final thoughts from you,

20:50 → 20:53

something that you would like to share to our viewers?

20:54 → 20:54

Yes. Sure.

20:54 → 20:58

So we discussed Axios, Mocha, and Chai,

20:58 → 20:59

but those are only tools.

20:59 → 21:00

Right?

21:00 → 21:05

And I think that the general knowledge or the general

21:05 → 21:10

thought is to simply cover API

21:10 → 21:14

with automation tests because we take care about regression.

21:14 → 21:17

We take care about security in our project.

21:18 → 21:22

And even for really short projects in

21:22 → 21:27

case of MVP, probably, the client

21:29 → 21:33

will continue this project in the future.

21:33 → 21:34

Right?

21:34 → 21:37

And thanks to those tests,

21:38 → 21:43

we are sure that when the team will change or

21:43 → 21:47

when, back end will, be bigger and

21:47 → 21:51

bigger, we are sure that some part of our our

21:51 → 21:55

projects, some part of our website will simply work,

21:55 → 21:59

and we can more rely on on our project.

21:59 → 22:03

The clients for our clients are

22:03 → 22:07

more happy because of better quality.

22:07 → 22:07

Alright.

22:07 → 22:11

And in my opinion, it's one of the basics

22:11 → 22:16

to implement automation API test

22:16 → 22:17

in our products.

22:17 → 22:18

Okay.

22:20 → 22:22

Alright then.

22:23 → 22:24

Thank you very much, Paweł,

22:25 → 22:30

and thank you all for watching today's show.

22:30 → 22:34

If you would like to talk a little bit more how you can

22:34 → 22:39

perform tests, how can you increase, for example,

22:39 → 22:42

security or performance of your application,

22:42 → 22:45

already existing or application that would be built somewhere

22:45 → 22:49

in the future, please feel free to reach out.

22:49 → 22:53

This was Merixstudio show. It's time to talk.

22:53 → 22:55

Our guest was Paweł Leszczyński,

22:55 → 22:57

our senior quality assurance tester.

22:57 → 22:59

Thank you very much, Paweł.

22:59 → 23:01

Thanks a lot.

23:01 → 23:03

In case of any questions,

23:03 → 23:05

I will be more than happy to to help.

23:05 → 23:09

Yes. So feel free to jump on the call. Drop us a line.

23:09 → 23:11

We are happy to talk,

23:11 → 23:15

and and please expect further shows

23:15 → 23:16

yet to come.

23:16 → 23:18

Thank you very much then. Have a great day.

Let's connect and build together