@@ -472,10 +472,8 @@ Superlists tests
472472====
473473
474474
475- // old content had a deliberate mistake where we started out without fixtures,
476- // decided not to bother with that.
477- // TODO: revisit that. it's a nice learning journey.
478475
476+ ////
479477
480478=== TODO: new plan
481479
@@ -489,6 +487,7 @@ this chapter is a decent first pass now, want to improve it as follows:
489487* see if just specifying it as a .js works, and we can do the chat about execution times. then switch to .mjs and imports
490488
491489* split out tests, especially sense-check bits, into 3 different its
490+ ////
492491
493492
494493
@@ -906,7 +905,9 @@ Ran 1 test in 3.023s
906905OK
907906----
908907
909- ((("", startref="JSTkey16")))Hooray! That's a commit!
908+ Hooray! That's a commit!
909+
910+ // ((("", startref="JSTkey16")))
910911
911912
912913[subs="specialcharacters,quotes"]
@@ -1161,68 +1162,58 @@ A Few Things That Didn't Make It
11611162
11621163TODO update this
11631164
1164- ((("JavaScript testing", "additional considerations for")))In
1165- this chapter I wanted to cover the very basics of JavaScript testing and how
1166- it fits into our TDD workflow in this chapter. Here are a few pointers for
1167- further research:
1168-
1169- * At the moment, our test only checks that the JavaScript works on one page.
1170- It works because we're including it in 'base.html', but if we'd only
1171- added it to 'home.html' the tests would still pass. It's a judgement
1172- call, but you could choose to write an extra test here.
1173-
1174- * ((("JavaScript testing", "syntax errors")))When
1175- writing JavaScript, get as much help from your editor as you can to
1176- avoid common "gotchas". Check out syntax/error-checking tools like
1177- "jslint" and "jshint", also known as "linters".
1165+ ((("JavaScript testing", "additional considerations for")))
1166+ In this chapter I wanted to cover the very basics of JavaScript testing
1167+ and how it fits into our TDD workflow in this chapter.
1168+ Here are a few pointers for further research:
11781169
1170+ * When writing JavaScript,
1171+ get as much help from your editor as you can to avoid common "gotchas".
1172+ Check out syntax/error-checking tools like `eslint` or `tsserver`.
1173+ ((("JavaScript testing", "syntax errors")))
11791174
1180- * ((("QUnit")))QUnit
1181- mainly expects you to "run" your tests using an actual web browser.
1175+ * The Jasmine Browser Runner mainly expects you to "run" your tests using an actual web browser.
11821176 This has the advantage that it's easy to create some HTML fixtures that
11831177 match the kind of HTML your site actually contains, for tests to run against.
11841178 But it's also possible to run JS tests from the command line. We'll see
11851179 an example in <<chapter_CI>>.
11861180
1187- * ((("MVC frameworks")))((("angular.js")))((("React")))The
1188- new shiny thing in the world of frontend development are MVC frameworks
1189- like 'angular.js' and React. ((("Jasmine")))Most
1190- tutorials for these use an RSpec-like
1191- assertion library called https://jasmine.github.io/[Jasmine]. If you're
1192- going to use one of them, you'll probably find life easier if you use Jasmine
1193- rather than QUnit.
11941181
1182+ There is more JavaScript fun in this book too!
1183+ Have a look at the <<appendix_rest_api,Rest API appendix>>
1184+ when you're ready for it.
1185+ ((("", startref="FTjava16")))
11951186
11961187
1188+ TODO: something about the balance between selenium and js unit tests.
11971189
1198-
1199- There is more JavaScript fun in this book too! Have a look at the
1200- <<appendix_rest_api,Rest API appendix>> when you're ready for it.((("", startref="FTjava16")))
1190+ ////
12011191
12021192
12031193[role="less_space pagebreak-before"]
12041194.JavaScript Testing Notes
12051195*******************************************************************************
12061196
1207- * ((("Selenium", "and JavaScript", secondary-sortas="JavaScript")))One
1208- of the great advantages of Selenium is that it allows you to test that
1197+ * ((("Selenium", "and JavaScript", secondary-sortas="JavaScript")))
1198+ One of the great advantages of Selenium is that it allows you to test that
12091199 your JavaScript really works, just as it tests your Python code.
12101200
1211- * ((("JavaScript testing", "test running libraries")))There
1212- are many JavaScript test running libraries out there. QUnit is closely
1213- tied to jQuery, which is the main reason I chose it.
1201+ * There are many JavaScript test running libraries out there.
1202+ Jasmine has been around for a while,
1203+ but others like Jest and Mocha are not dissimilar.
1204+ ((("JavaScript testing", "test running libraries")))
12141205
1215- * ((("JavaScript testing", "managing global state")))((("global state")))No
1206+ *
1207+ ((("JavaScript testing", "managing global state")))
1208+ ((("global state")))
1209+ No
12161210matter which testing library you use, you'll always need to find solutions
12171211 to the main challenge of JavaScript testing, which is about 'managing global
12181212 state'. That includes:
12191213 - the DOM / HTML fixtures
12201214 - namespacing
12211215 - understanding and controlling execution order.
1222-
1223- * I don't really mean it when I say that JavaScript is awful. It can actually
1224- be quite fun. But I'll say it again: make sure you've read
1225- <<jsgoodparts,'JavaScript: The Good Parts'>>.
1216+ ////
12261217
12271218*******************************************************************************
12281219
0 commit comments