JSJ 341: Testing in JavaScript with Gil Tayar


Manage episode 222041709 series 180546
By Discovered by Player FM and our community — copyright is owned by the publisher, not Player FM, and audio streamed directly from their servers.


  • Aimee Knight
  • AJ O’Neal
  • Charles Max Wood

Special Guest: Gil Tayar

In this episode, the panel talks with Gil Tayar who is currently residing in Tel Aviv and is a software engineer. He is currently the Senior Architect at Applitools in Israel. The panel and the guest talk about the different types of tests and when/how one is to use a certain test in a particular situation. They also mention Node, React, Selenium, Puppeteer, and much more!

Show Topics:

0:00 – Advertisement: KENDO UI

0:35 – Chuck: Our panel is AJ, Aimee, myself – and our special guest is Gil Tayar. Tell us why you are famous!

1:13 – Gil talks about where he resides and his background.

2:27 – Chuck: What is the landscape like now with testing and testing tools now?

2:39 – Guest: There is a huge renaissance with the JavaScript community. Testing has moved forward in the frontend and backend. Today we have lots of testing tools. We can do frontend testing that wasn’t possible 5 years ago. The major change was React.

The guest talks about Node, React, tools, and more!

4:17 – Aimee: I advocate for tests and testing. There is a grey area though...how do you treat that? If you have to get something into production, but it’s not THE thing to get into production, does that fall into product or...what?

5:02 – Guest: We decided to test everything in the beginning. We actually cam through and did that and since then I don’t think I can use the right code without testing. There are a lot of different situations, though, to consider.

The guest gives hypothetical situations that people could face.

6:27 – Aimee.

6:32 – Guest: The horror to changing code without tests, I don’t know, I haven’t done that for a while. You write with fear in your heart. Your design is driven by fear, and not what you think is right. In the beginning don’t write those tests, but...

7:22 – Aimee: I totally agree and I could go on and on and on.

7:42 – Panel: I want to do tests when I know they will create value. I don’t want to do it b/c it’s a mundane thing. Secondly, I find that some times I am in a situation where I cannot write the test b/c I would have to know the business logic is correct. I am in this discovery mode of what is the business logic? I am not just building your app.

I guess I just need advice in this area, I guess.

8:55 – Guest gives advice to panelist’s question. He mentions how there are two schools of thought.

10:20 – Guest: Don’t mock too much.

10:54 – Panel: Are unit tests the easiest? I just reach for unit testing b/c it helps me code faster. But 90% of my code is NOT that.

11:18 – Guest: Exactly! Most of our test is glue – gluing together a bunch of different stuff! Those are best tested as a medium-sized integration suite.

12:39 – Panel: That seems like a lot of work, though! I loathe the database stuff b/c they don’t map cleanly. I hate this database stuff.

13:06 – Guest: I agree, but don’t knock the database, but knock the level above the database.

13:49 – Guest: Yes, it takes time! Building the script and the testing tools, but when you have it then adding to it is zero time. Once you are in the air it’s smooth sailing.

14:17 – Panel: I guess I can see that. I like to do the dumb-way the first time. I am not clear on the transition.

14:47 – Guest: Write the code, and then write the tests.

The guest gives a hypothetical situation on how/when to test in a certain situation.

16:25 – Panel: Can you talk about that more, please?

16:50 – Guest: Don’t have the same unit – do browser and business logic stuff separated. The real business logic stuff needs to be above that level. First principle is separation of concerns.

18:04 – Panel talks about dependency interjection and asks a question.

18:27 – Guest: What I am talking about very, very light inter-dependency interjection.

19:19 – Panel: You have a main function and you are doing requires in the main function. You are passing the pieces of that into the components that need it.

19:44 – Guest: I only do it when it’s necessary; it’s not a religion for me. I do it only for those layers that I know will need to be mocked; like database layers, etc.

20:09 – Panel.

20:19 – Guest: It’s taken me 80 years to figure out, but I have made plenty of mistakes a long the way. A test should run for 2-5 minutes max for package.

20:53 – Panel: What if you have a really messy legacy system? How do you recommend going into that? Do you write tests for things that you think needs to get tested?

21:39 – Guest answers the question and mentions Selenium!

24:27 – Panel: I like that approach.

24:35 – Chuck: When you say integration test what do you mean?

24:44 – Guest: Integration tests aren’t usually talked about. For most people it’s tests that test the database level against the database. For me, the integration tests are taking a set of classes as they are in the application and testing them together w/o the...so they can run in millisecond time.

26:54 – Advertisement – Sentry.io

27:52 – Chuck: How much do the tools matter?

28:01 – Guest: The revolutions matter. Whether you use Jasmine or Mocha or whatever I don’t think it matters. The tests matter not the tools.

28:39 – Aimee: Yes and no. I think some tools are outdated.

28:50 – Guest: I got a lot of flack about my blog where I talk about Cypress versus Selenium. I will never use Jasmine. In the end it’s the

29:29 – Aimee: I am curious would you be willing to expand on what the Selenium folks were saying about Puppeteer and others may not provide?

29:54 – Guest: Cypress was built for frontend developers. They don’t care about cross browser, and they tested in Chrome. Most browsers are typically the same. Selenium was built with the QA mindset – end to end tests that we need to do cross browser.

The guest continues with this topic.

30:54 – Aimee mentions Cypress.

31:08 – Guest: My guessing is that their priority is not there. I kind of agree with them.

31:21 – Aimee: I think they are focusing on mobile more.

31:24 – Guest: I think cross browser testing is less of an issue now. There is one area that is important it’s the visual area! It’s important to test visually across these different browsers.

32:32 – Guest: Selenium is a Swiss knife – it can do everything.

33:32 – Chuck: I am thinking about different topics to talk about. I haven’t used Puppeteer. What’s that about?

33:49 – Guest: Puppeteer is much more like Selenium. The reason why it’s great is b/c Puppeteer will always be Google Chrome.

35:42 – Chuck: When should you be running your tests? I like to use some unit tests when I am doing my development but how do you break that down?

36:06 – Guest.

38:30 – Chuck: You run tests against production?

38:45 – Guest: Don’t run tests against production...let me clarify!

39:14 – Chuck.

39:21 – Guest: When I am talking about integration testing in the backend...

40:37 – Chuck asks a question.

40:47 – Guest: I am constantly running between frontend and backend.

I didn’t know how to run tests for frontend. I had to invent a new thing and I “invented” the package JS DONG. It’s an implementation of Dong in Node. I found out that I wasn’t the only one and that there were others out there, too.

43:14 – Chuck: Nice! You talked in the prep docs that you urged a new frontend developer to not run the app in the browser for 2 months?

43:25 – Guest: Yeah, I found out that she was running the application...she said she knew how to write tests. I wanted her to see it my way and it probably was a radical train-of-thought, and that was this...

44:40 – Guest: Frontend is so visual.

45:12 – Chuck: What are you working on now?

45:16 – Guest: I am working with Applitools and I was impressed with what they were doing.

The guest goes into further detail.

46:08 – Guest: Those screenshots are never the same.

48:36 – Panel: It’s...comparing the output to the static site to the...

48:50 – Guest: Yes, that static site – if you have 30 pages in your app – most of those are the same. We have this trick where we don’t upload it again and again. Uploading the whole static site is usually very quick. The second thing is we don’t wait for the results. We don’t wait for the whole rendering and we continue with the tests.

50:28 – Guest: I am working mostly (right now) in backend.

50:40 – Chuck: Anything else? Picks!

50:57 – Advertisement: Get A Coder Job!

END – Advertisement: CacheFly!








470 episodes available. A new episode about every 3 days averaging 50 mins duration .