Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 75 lines (61 sloc) 2.044 kB
5641a2b @benjaminoakes RailsConf 2011 notes, verbatim from back in... May 2011 (how time flies)
benjaminoakes authored
1 Getting Started with JavaScript Testing
2 =======================================
3
4 * JS as a first class citizen -- it's real code
5
6 * integration: AJAX, complicated DOM, etc
7 * Capybara is great for integration testing
8 * Simulates user behavior
9 * Switch seamlessly between drivers
10 * JS targeted:
11 * Selenium
12 * Akephalos (HTMLUnit based, slower)
13 * capybara-envjs (bad support)
14 * capybara-webkit (unproven
15
16 * can use rack-test to do non-JS
17
18 * gem 'capybara-enjs'
19
20 it 'does (with JS)', :js => true do
21 # ...
22 end
23
24 * Can do in Cucumber too
25
26 * Best Practices:
27 * Helper modules (e.g. for things like sign_in_as(name))
28 * Use selectors to get back in your domain language
29 * Assert on things you can see
30 * Not URLs
31 * Not cookies
32 * Not session
33 * Not application state
34 * This is less brittle, doesn't depend on underlying implementation
35 * Use field labels, not field names
36 * Use domain stuff, not implmenetation
37 * Unit testing: standaolone logic
38 * Favorite: Jasmine
39 * Stable, full featured, general purpose
40 * Evergreen packages up Jasmine
41 * Evergreen: /evergreen
42 * Allows commandline testing
43 * Evergreen:
44 * Nice requires
45 * Templates (HTML snippets)
46 * toHaveElement (in spec_helper)
47 * Does CoffeeScript based on filename
48
49 * Suggestions
50 * Testable JS code
51 * Create abstractions
52 * Keep consistent feel to JS (functional or OO, pick one)
53 * Separate files (esp. with asset pipeline), not just application.js TODO
54 * *Mostly* test event bindings, maybe integration, still experiment
55 * Custom matchers are good
56 * Isolate AJAX to avoid brittleness
57 * Maybe mock AJAX
58 * Simplify your DOM
59
60 * Qs
61 * JSTestDriver?
62 * Why have to click?
63
64
65 Testing
66 =======
67
68 * OBJECTS
69 * individual components key
70 * Jasmine: Scenario, Given, When, Then
71 * Act like a user
72 * Unit tests: systemic (internal quality)
73 * Can split into controllers, etc
74
Something went wrong with that request. Please try again.