In this video, we're going to talk about Foleo in much greater detail, as I told you before, Foleo
is a customizable test framework to build your own custom test framework as well.
And this is the foundation for the playwright Destra.
Well, as I said, Foleo is based on the concept of test fixtures.
The test fixtures are used to establish an environment for each test, giving the test everything it
needs and nothing else.
Right.
That's the that's the uses of test fixtures, because if you see any unit or J unit are test in G,
they actually has something called a test picture.
We try to use this before test or after test, especially to set up the things that is required for
the test to basically execute.
And that's exactly is the idea of the test fixture, and that's exactly what this folio is also going
to be doing.
So this is how this is going to be setting things up for us.
And we can extend our own test fixture based on this particular folio of the example of extending our
own fixture is going to look something like this.
As you can see, I'm actually creating a simper extended test fixture or a browser fixture in this place
where it is going to give me a different path of different browsers.
It's very, very simple.
Basically, what it does is it has an import folio as base from playwrite and export expect from the
folio.
As you can see, I'm just trying to get these details and then I'm creating my own type as browsers
where I'm specifying Chrome, Firefox and edge of type string.
And then I'm going to extend the browser type in such a way that if you're going to call the Chrome
from the fixture, then it is going to give me the path of that particular browser.
That's it.
That's what it is doing.
There is no intelligent thing happening over here.
So this browser tab that I have specified can be of any type.
I mean, it can be your own browser options.
It can be of your own page or it can be of your own context options.
It can be of anything.
I mean, this browser options or the context options are actually from the playwright.
So we can extend these types over here in the fixtures and then we can modify its behavior and then
we can set things up for it.
And then we can give that particular data to the caller, which is nothing but our test.
So basically these fixtures are going to be consumed by our test and then we are going to be ensuring
that our test runs start any problem.
So this is what the whole idea or the purpose of extending our own fixtures.
So as you can see over here, I have created a very, very super simple file with the fixture where
I'm going to specify the or get the part.
But only thing, as you can see here, this is the terminology to follow while you called it in it is
that you need to run.
You want to call this a where in the return this particular value or the value that you have set over
here, which is very, very simple.
And then once everything has been done in this particular fixture, you need to build it and then you
to return different constant that you are going to be returning to your test.
So as you can see, I've done it here, but I have not returned that describe.
So the describe is not going to be available for your test if you're going to be consuming this particular
fixture.
So one more thing is that if this particular fixture is now available while you consume it, you need
to consume this particular fixture rather again, consuming the add puppeteer slash test like how we
did in our earlier video.
So the consumption or the accessing this particular extended fixture is going to look something like
this.
As you can see, I'm going to be importing it and expect from the fixture, rather, the at playwrite
slash test.
And then I'm actually going to be getting the pad, as you can see over here.
So I'm going to be doing and expect as well over here.
And it just works fine without any problems.
So if I call the Crome, then it's going to give me the pad and then I can match if the pad actually
matches, like how it is specified in my existing fixture setup.
So this is the simplest way that we can actually write our code and see how it actually works using
the test fixtures functionality of the folio as you see everything in action and listen to how things
work.
The file that I'm going to flip to my business record.
All right.
So before even going to this particular code that we have been discussing so far, I'm just going to
show you how the folio is going to look like.
And as you can see, if you come down a bit or here, the test run, initially, it tells that there
is a Foleo parameter.
So what is this folio?
So if I just open this folio, you can see that the folio is a separate project.
Created by the Microsoft team and this foliar tell us it's a customizable test framework to build your
own test framework and it has some of the basic concepts, as you can see or hear, to tell you how
you can create your own.
I mean, without fixtures, you need to do a lot of things like before and after.
Before each.
After each, for each and every test.
In each and every files that you will be working.
But using this fixtures, you can just call the particular file and then you can keep extending it pretty
much easily without having to have all these different extra options that you need to be doing.
So that is really a pain.
And those things are taken care of by this particular fixture.
And there are many different options, many different details available here.
And again, those are very, very simple.
We are going to be talking about most of them in this particular section of this course.
But yeah, this is what is Foleo.
So now we are going to be working with Foleo.
So I'm going to do one more thing because I'm just going to create a new folder and I'm going to call
this as a Foleo example, because this is going to be a FOLIA specific, not the one which we were discussing
before.
So it's aren't astronauts of Foleo specific?
I'm just deviating a bit from the test or to the Foleo is because you need to understand what is Foleo
and how to to work with Foleo in more detail, because without having the knowledge of Foleo and the
test fixtures, if I directly tell about the fixtures, then it's like an half baked information, which
I don't really need or want you to understand.
So this way it is easier to understand as well.
So I'm just going to create a file name a fixture, Dods.
And again, the filename can be anything but I'm just giving a file name as a fixture here so that it's
more meaningful as well.
And I'm just going to do an import here and I'm going to do something I import from.
And again, I'm just going to use it as playwrite test, which is the one which we used in our early
video as well.
And over here, I'm just going to do this Foleo as base.
I mean, you can use directly as Foleo if you want, but this is something looks like more a better
way of doing it in terms of the practices.
So I'm just going to do exactly the same code that we saw in our slide there.
Like, I'm just going to create different variables for this particular type, like Firefox, Chrome
and Etch like this.
And then I'm just going to create a const fixtures that I'm just going to say because dot extend of
the type, which is nothing but the browsers.
And after that I'm just going to say, all right, fixtures, if I hear Dot, you can see that it brings
me up automatically this chrome edge in Firefox, which is pretty cool.
So now it knows that I'm actually going to be extending this particular this particular types that I
have over there.
So I'm just going to say chrome dot init method where I'm just going to say.
All right.
Is think of the because I'm not going to really pass anything there on the parameter side, so I'm just
going to leave them as it is and I'm going to tell.
All right.
So I am going to wait for run.
I'm just going to give you a part if somebody calls the chrome for me.
So the part is going to be very, very simple.
All I'm going to do is like I'm just going to create a dummy part.
Um, I'm just going to use something like this.
So that's it.
So if I do call the chrome from some of my test, it is going to return me or run this thing for me,
returns me this particular part in a string type.
So if I specify if I have like a Firefox or the browser, then I can do something like this and just
worse find that only problem.
So this is the very, very super simple code that we saw in the slide.
And that's exactly what I'm going to be doing over here as well.
But just that we also need to use this constant as Foleo, because this is what is going to be the FOLIA
parameter, which is going to be used within our consumption end, which is going to be our test.
So we need to create this constant where I'm going to tell that Fixer's dot build.
And I also need to export the constant of it as Foleo DARD, I guess it's it.
And if I don't specify the described and the describe, it's not going to be available.
So if I just specify that describe then just to describe as well something like this.
And we also need to export the they expect so you can create something like the export of the concept
of X expect is equal to Foleo dot expect or you can also do something like this.
You can do anything however you want.
Yep.
And this is how we can actually create a fixture file from the Folio and so we can then create and consumption
end and we can see how we can consume this particular test that we have created or the fixes that we
have created and see how it actually works, which will be doing in our next video.