For example, if you have a Node server using Express and you write a Jasmine test to make sure POST /someroute gives you the JSON you expect, is that still considered unit testing? I know it doesn't seem to fit the strict definition of the smallest testable part of an application. So if not, is there a certain term for this type of testing of routes?
2 Answers
According to wikipedia? Sure:
In computer programming, unit testing is a software testing method by which individual units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures, are tested to determine whether they are fit for use.
In other words: anything you somehow do to test a program can be considered a unit test.
But of course, you are probably asking about unit tests in the more narrow meaning, as defined by art-of-unit-testing for example. One aspect there:
Runs in memory (no DB or File access, for example)
Or in other words: a true unit test tests a single unit in isolation.
Coming from there: I would not consider the described approach as unit testing:
- you are not testing a single unit, but an API endpoint as a whole - you exercise the API endpoint, and you expect your implementation to return a value that can be the result of many internal steps
- as you are not describing any means to that - it seems that your unit is also not isolated from file system/database/...
In that sense: I think what you are talking about is much more a function/integration test than a true unit test.

- 137,827
- 25
- 176
- 248
-
I wouldn't give much credence to that Wikipedia article. I prefer [Fowler's article](https://martinfowler.com/bliki/UnitTest.html), who, together with Kent Beck (creator of JUnit, main proponent of TDD and XP), is IMO a much more reliable source. And for these guys, just about any automated test written by a programmer *is* a unit test. The truth of the matter is that there is no universal agreement on what exactly is or is not a unit test. Personally, I think the important distinction that people should care about is what makes for "good" vs "bad" tests. – Rogério Aug 16 '17 at 02:16
It's considered unit-testing for the server.
It would be outside the scope of testing your client side. Because the server is already testing that. For the client/front end you should only test if your application works as expected when it gets a 200, 400, 500, etc. Also see here

- 33,269
- 19
- 164
- 293