File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ Why Can't I Test My Javascript
2
+
3
+ need to split js code into testable units, not spaghetti code.
4
+
5
+ (most) everything in js is an object. we should test objects.
6
+
7
+ don't put logic in the DOM.
8
+
9
+ DOM is just an object.
10
+
11
+ Test js the same way we test everything else. Add structure to js and write it in a testable object-oriented manner.
12
+
13
+ what should tests do: ensure value (catching bugs is a side effect of tests)
14
+
15
+ Two types of value:
16
+ * external value - end user will experience what app promises to do
17
+ * use end-to-end acceptance test
18
+ * does it meet the external value?
19
+ * do we understand the external value?
20
+ * internal value - easy to change stuff within app w/o headaches
21
+ * acceptance tests != internal quality
22
+ * need isolated unit tests
23
+ * The act of writing test gives feedback on quality of code
24
+ * running a (successful) unit test tells us we haven't broken any object
25
+ * a unit test will NOT tell us if system works together as a whole
26
+
27
+ Unit tests tell you that you built the system right, while Acceptance/Integration tests tell you that you built the right system.
28
+
29
+ Acceptance/Integration tests:
30
+ * poke around at UI (as a user would) and verify expected functionality
31
+
32
+ Unit tests:
33
+ * tests written for devs or development purposes
34
+
35
+
36
+
37
+
You can’t perform that action at this time.
0 commit comments